View Javadoc
1   /*
2    * Copyright 2020 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.channel.socket;
17  
18  import io.netty.buffer.ByteBufAllocator;
19  import io.netty.channel.ChannelConfig;
20  import io.netty.channel.ChannelHandlerContext;
21  import io.netty.channel.ChannelInboundHandler;
22  import io.netty.channel.ChannelOption;
23  import io.netty.channel.MessageSizeEstimator;
24  import io.netty.channel.RecvByteBufAllocator;
25  import io.netty.channel.WriteBufferWaterMark;
26  
27  /**
28   * A {@link ChannelConfig} for a {@link DuplexChannel}.
29   *
30   * <h3>Available options</h3>
31   *
32   * In addition to the options provided by {@link ChannelConfig},
33   * {@link DuplexChannelConfig} allows the following options in the option map:
34   *
35   * <table border="1" cellspacing="0" cellpadding="6">
36   * <tr>
37   * <td>{@link ChannelOption#ALLOW_HALF_CLOSURE}</td><td>{@link #setAllowHalfClosure(boolean)}</td>
38   * </tr>
39   * </table>
40   */
41  public interface DuplexChannelConfig extends ChannelConfig {
42  
43      /**
44       * Returns {@code true} if and only if the channel should not close itself when its remote
45       * peer shuts down output to make the connection half-closed.  If {@code false}, the connection
46       * is closed automatically when the remote peer shuts down output.
47       */
48      boolean isAllowHalfClosure();
49  
50      /**
51       * Sets whether the channel should not close itself when its remote peer shuts down output to
52       * make the connection half-closed.  If {@code true} the connection is not closed when the
53       * remote peer shuts down output. Instead,
54       * {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)}
55       * is invoked with a {@link ChannelInputShutdownEvent} object. If {@code false}, the connection
56       * is closed automatically.
57       */
58      DuplexChannelConfig setAllowHalfClosure(boolean allowHalfClosure);
59  
60      @Override
61      @Deprecated
62      DuplexChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead);
63  
64      @Override
65      DuplexChannelConfig setWriteSpinCount(int writeSpinCount);
66  
67      @Override
68      DuplexChannelConfig setAllocator(ByteBufAllocator allocator);
69  
70      @Override
71      DuplexChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator);
72  
73      @Override
74      DuplexChannelConfig setAutoRead(boolean autoRead);
75  
76      @Override
77      DuplexChannelConfig setAutoClose(boolean autoClose);
78  
79      @Override
80      DuplexChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator);
81  
82      @Override
83      DuplexChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark);
84  }