View Javadoc
1   /*
2    * Copyright 2016 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.channel.Channel;
19  import io.netty.channel.ChannelFuture;
20  import io.netty.channel.ChannelPromise;
21  
22  import java.net.Socket;
23  
24  /**
25   * A duplex {@link Channel} that has two sides that can be shutdown independently.
26   */
27  public interface DuplexChannel extends Channel {
28      /**
29       * Returns {@code true} if and only if the remote peer shut down its output so that no more
30       * data is received from this channel.  Note that the semantic of this method is different from
31       * that of {@link Socket#shutdownInput()} and {@link Socket#isInputShutdown()}.
32       */
33      boolean isInputShutdown();
34  
35      /**
36       * @see Socket#shutdownInput()
37       */
38      ChannelFuture shutdownInput();
39  
40      /**
41       * Will shutdown the input and notify {@link ChannelPromise}.
42       *
43       * @see Socket#shutdownInput()
44       */
45      ChannelFuture shutdownInput(ChannelPromise promise);
46  
47      /**
48       * @see Socket#isOutputShutdown()
49       */
50      boolean isOutputShutdown();
51  
52      /**
53       * @see Socket#shutdownOutput()
54       */
55      ChannelFuture shutdownOutput();
56  
57      /**
58       * Will shutdown the output and notify {@link ChannelPromise}.
59       *
60       * @see Socket#shutdownOutput()
61       */
62      ChannelFuture shutdownOutput(ChannelPromise promise);
63  
64      /**
65       * Determine if both the input and output of this channel have been shutdown.
66       */
67      boolean isShutdown();
68  
69      /**
70       * Will shutdown the input and output sides of this channel.
71       * @return will be completed when both shutdown operations complete.
72       */
73      ChannelFuture shutdown();
74  
75      /**
76       * Will shutdown the input and output sides of this channel.
77       * @param promise will be completed when both shutdown operations complete.
78       * @return will be completed when both shutdown operations complete.
79       */
80      ChannelFuture shutdown(ChannelPromise promise);
81  }