1 /* 2 * Copyright 2009 Red Hat, Inc. 3 * 4 * Red Hat licenses this file to you under the Apache License, version 2.0 5 * (the "License"); you may not use this file except in compliance with the 6 * 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 20 import org.jboss.netty.channel.ChannelConfig; 21 22 /** 23 * A {@link ChannelConfig} for a {@link SocketChannel}. 24 * 25 * <h3>Available options</h3> 26 * 27 * In addition to the options provided by {@link ChannelConfig}, 28 * {@link SocketChannelConfig} allows the following options in the option map: 29 * 30 * <table border="1" cellspacing="0" cellpadding="6"> 31 * <tr> 32 * <th>Name</th><th>Associated setter method</th> 33 * </tr><tr> 34 * <td>{@code "keepAlive"}</td><td>{@link #setKeepAlive(boolean)}</td> 35 * </tr><tr> 36 * <td>{@code "reuseAddress"}</td><td>{@link #setReuseAddress(boolean)}</td> 37 * </tr><tr> 38 * <td>{@code "soLinger"}</td><td>{@link #setSoLinger(int)}</td> 39 * </tr><tr> 40 * <td>{@code "tcpNoDelay"}</td><td>{@link #setTcpNoDelay(boolean)}</td> 41 * </tr><tr> 42 * <td>{@code "receiveBufferSize"}</td><td>{@link #setReceiveBufferSize(int)}</td> 43 * </tr><tr> 44 * <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td> 45 * </tr><tr> 46 * <td>{@code "trafficClass"}</td><td>{@link #setTrafficClass(int)}</td> 47 * </tr> 48 * </table> 49 * 50 * @author <a href="http://www.jboss.org/netty/">The Netty Project</a> 51 * @author <a href="http://gleamynode.net/">Trustin Lee</a> 52 * 53 * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $ 54 */ 55 public interface SocketChannelConfig extends ChannelConfig { 56 57 /** 58 * Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_TCPNODELAY}</a> option. 59 */ 60 boolean isTcpNoDelay(); 61 62 /** 63 * Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_TCPNODELAY}</a> option. 64 */ 65 void setTcpNoDelay(boolean tcpNoDelay); 66 67 /** 68 * Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_LINGER}</a> option. 69 */ 70 int getSoLinger(); 71 72 /** 73 * Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_LINGER}</a> option. 74 */ 75 void setSoLinger(int soLinger); 76 77 /** 78 * Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_SNDBUF}</a> option. 79 */ 80 int getSendBufferSize(); 81 82 /** 83 * Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_SNDBUF}</a> option. 84 */ 85 void setSendBufferSize(int sendBufferSize); 86 87 /** 88 * Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option. 89 */ 90 int getReceiveBufferSize(); 91 92 /** 93 * Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option. 94 */ 95 void setReceiveBufferSize(int receiveBufferSize); 96 97 /** 98 * Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_KEEPALIVE}</a> option. 99 */ 100 boolean isKeepAlive(); 101 102 /** 103 * Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_KEEPALIVE}</a> option. 104 */ 105 void setKeepAlive(boolean keepAlive); 106 107 /** 108 * Gets the traffic class. 109 */ 110 int getTrafficClass(); 111 112 /** 113 * Sets the traffic class as specified in {@link Socket#setTrafficClass(int)}. 114 */ 115 void setTrafficClass(int trafficClass); 116 117 /** 118 * Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option. 119 */ 120 boolean isReuseAddress(); 121 122 /** 123 * Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option. 124 */ 125 void setReuseAddress(boolean reuseAddress); 126 127 /** 128 * Sets the performance preferences as specified in 129 * {@link Socket#setPerformancePreferences(int, int, int)}. 130 */ 131 void setPerformancePreferences( 132 int connectionTime, int latency, int bandwidth); 133 }