View Javadoc
1   /*
2    * Copyright 2012 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    *   http://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 org.jboss.netty.channel.socket;
17  
18  import java.net.Socket;
19  import java.net.StandardSocketOptions;
20  
21  import org.jboss.netty.channel.ChannelConfig;
22  
23  /**
24   * A {@link ChannelConfig} for a {@link SocketChannel}.
25   *
26   * <h3>Available options</h3>
27   *
28   * In addition to the options provided by {@link ChannelConfig},
29   * {@link SocketChannelConfig} allows the following options in the option map:
30   *
31   * <table border="1" cellspacing="0" cellpadding="6">
32   * <tr>
33   * <th>Name</th><th>Associated setter method</th>
34   * </tr><tr>
35   * <td>{@code "keepAlive"}</td><td>{@link #setKeepAlive(boolean)}</td>
36   * </tr><tr>
37   * <td>{@code "reuseAddress"}</td><td>{@link #setReuseAddress(boolean)}</td>
38   * </tr><tr>
39   * <td>{@code "soLinger"}</td><td>{@link #setSoLinger(int)}</td>
40   * </tr><tr>
41   * <td>{@code "tcpNoDelay"}</td><td>{@link #setTcpNoDelay(boolean)}</td>
42   * </tr><tr>
43   * <td>{@code "receiveBufferSize"}</td><td>{@link #setReceiveBufferSize(int)}</td>
44   * </tr><tr>
45   * <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td>
46   * </tr><tr>
47   * <td>{@code "trafficClass"}</td><td>{@link #setTrafficClass(int)}</td>
48   * </tr>
49   * </table>
50   */
51  public interface SocketChannelConfig extends ChannelConfig {
52  
53      /**
54       * Gets the {@link StandardSocketOptions#TCP_NODELAY} option.
55       */
56      boolean isTcpNoDelay();
57  
58      /**
59       * Sets the {@link StandardSocketOptions#TCP_NODELAY} option.
60       */
61      void setTcpNoDelay(boolean tcpNoDelay);
62  
63      /**
64       * Gets the {@link StandardSocketOptions#SO_LINGER} option.
65       */
66      int getSoLinger();
67  
68      /**
69       * Sets the {@link StandardSocketOptions#SO_LINGER} option.
70       */
71      void setSoLinger(int soLinger);
72  
73      /**
74       * Gets the {@link StandardSocketOptions#SO_SNDBUF} option.
75       */
76      int getSendBufferSize();
77  
78      /**
79       * Sets the {@link StandardSocketOptions#SO_SNDBUF} option.
80       */
81      void setSendBufferSize(int sendBufferSize);
82  
83      /**
84       * Gets the {@link StandardSocketOptions#SO_RCVBUF} option.
85       */
86      int getReceiveBufferSize();
87  
88      /**
89       * Sets the {@link StandardSocketOptions#SO_RCVBUF} option.
90       */
91      void setReceiveBufferSize(int receiveBufferSize);
92  
93      /**
94       * Gets the {@link StandardSocketOptions#SO_KEEPALIVE} option.
95       */
96      boolean isKeepAlive();
97  
98      /**
99       * Sets the {@link StandardSocketOptions#SO_KEEPALIVE} option.
100      */
101     void setKeepAlive(boolean keepAlive);
102 
103     /**
104      * Gets the {@link StandardSocketOptions#IP_TOS} option.
105      */
106     int getTrafficClass();
107 
108     /**
109      * Sets the {@link StandardSocketOptions#IP_TOS} option.
110      */
111     void setTrafficClass(int trafficClass);
112 
113     /**
114      * Gets the {@link StandardSocketOptions#SO_REUSEADDR} option.
115      */
116     boolean isReuseAddress();
117 
118     /**
119      * Sets the {@link StandardSocketOptions#SO_REUSEADDR} option.
120      */
121     void setReuseAddress(boolean reuseAddress);
122 
123     /**
124      * Sets the performance preferences as specified in
125      * {@link Socket#setPerformancePreferences(int, int, int)}.
126      */
127     void setPerformancePreferences(
128             int connectionTime, int latency, int bandwidth);
129 }