1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.mina.transport.socket; 21 22 import java.net.Socket; 23 24 import org.apache.mina.core.session.IoSessionConfig; 25 26 /** 27 * An {@link IoSessionConfig} for socket transport type. 28 * 29 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 30 */ 31 public interface SocketSessionConfig extends IoSessionConfig { 32 /** 33 * @see Socket#getReuseAddress() 34 * 35 * @return <tt>true</tt> if SO_REUSEADDR is enabled. 36 */ 37 boolean isReuseAddress(); 38 39 /** 40 * @see Socket#setReuseAddress(boolean) 41 * 42 * @param reuseAddress Tells if SO_REUSEADDR is enabled or disabled 43 */ 44 void setReuseAddress(boolean reuseAddress); 45 46 /** 47 * @see Socket#getReceiveBufferSize() 48 * 49 * @return the size of the receive buffer 50 */ 51 int getReceiveBufferSize(); 52 53 /** 54 * @see Socket#setReceiveBufferSize(int) 55 * 56 * @param receiveBufferSize The size of the receive buffer 57 */ 58 void setReceiveBufferSize(int receiveBufferSize); 59 60 /** 61 * @see Socket#getSendBufferSize() 62 * 63 * @return the size of the send buffer 64 */ 65 int getSendBufferSize(); 66 67 /** 68 * @see Socket#setSendBufferSize(int) 69 * 70 * @param sendBufferSize The size of the send buffer 71 */ 72 void setSendBufferSize(int sendBufferSize); 73 74 /** 75 * @see Socket#getTrafficClass() 76 * 77 * @return the traffic class 78 */ 79 int getTrafficClass(); 80 81 /** 82 * @see Socket#setTrafficClass(int) 83 * 84 * @param trafficClass The traffic class to set, one of <tt>IPTOS_LOWCOST</tt> (0x02) 85 * <tt>IPTOS_RELIABILITY</tt> (0x04), <tt>IPTOS_THROUGHPUT</tt> (0x08) or <tt>IPTOS_LOWDELAY</tt> (0x10) 86 */ 87 void setTrafficClass(int trafficClass); 88 89 /** 90 * @see Socket#getKeepAlive() 91 * 92 * @return <tt>true</tt> if <tt>SO_KEEPALIVE</tt> is enabled. 93 */ 94 boolean isKeepAlive(); 95 96 /** 97 * @see Socket#setKeepAlive(boolean) 98 * 99 * @param keepAlive if <tt>SO_KEEPALIVE</tt> is to be enabled 100 */ 101 void setKeepAlive(boolean keepAlive); 102 103 /** 104 * @see Socket#getOOBInline() 105 * 106 * @return <tt>true</tt> if <tt>SO_OOBINLINE</tt> is enabled. 107 */ 108 boolean isOobInline(); 109 110 /** 111 * @see Socket#setOOBInline(boolean) 112 * 113 * @param oobInline if <tt>SO_OOBINLINE</tt> is to be enabled 114 */ 115 void setOobInline(boolean oobInline); 116 117 /** 118 * Please note that enabling <tt>SO_LINGER</tt> in Java NIO can result 119 * in platform-dependent behavior and unexpected blocking of I/O thread. 120 * 121 * @see Socket#getSoLinger() 122 * @see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6179351">Sun Bug Database</a> 123 * 124 * @return The value for <tt>SO_LINGER</tt> 125 */ 126 int getSoLinger(); 127 128 /** 129 * Please note that enabling <tt>SO_LINGER</tt> in Java NIO can result 130 * in platform-dependent behavior and unexpected blocking of I/O thread. 131 * 132 * @param soLinger Please specify a negative value to disable <tt>SO_LINGER</tt>. 133 * 134 * @see Socket#setSoLinger(boolean, int) 135 * @see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6179351">Sun Bug Database</a> 136 */ 137 void setSoLinger(int soLinger); 138 139 /** 140 * @see Socket#getTcpNoDelay() 141 * 142 * @return <tt>true</tt> if <tt>TCP_NODELAY</tt> is enabled. 143 */ 144 boolean isTcpNoDelay(); 145 146 /** 147 * @see Socket#setTcpNoDelay(boolean) 148 * 149 * @param tcpNoDelay <tt>true</tt> if <tt>TCP_NODELAY</tt> is to be enabled 150 */ 151 void setTcpNoDelay(boolean tcpNoDelay); 152 }