001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.mina.transport.socket; 021 022import java.net.Socket; 023 024import org.apache.mina.core.session.IoSessionConfig; 025 026/** 027 * An {@link IoSessionConfig} for socket transport type. 028 * 029 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 030 */ 031public interface SocketSessionConfig extends IoSessionConfig { 032 /** 033 * @see Socket#getReuseAddress() 034 * 035 * @return <tt>true</tt> if SO_REUSEADDR is enabled. 036 */ 037 boolean isReuseAddress(); 038 039 /** 040 * @see Socket#setReuseAddress(boolean) 041 * 042 * @param reuseAddress Tells if SO_REUSEADDR is enabled or disabled 043 */ 044 void setReuseAddress(boolean reuseAddress); 045 046 /** 047 * @see Socket#getReceiveBufferSize() 048 * 049 * @return the size of the receive buffer 050 */ 051 int getReceiveBufferSize(); 052 053 /** 054 * @see Socket#setReceiveBufferSize(int) 055 * 056 * @param receiveBufferSize The size of the receive buffer 057 */ 058 void setReceiveBufferSize(int receiveBufferSize); 059 060 /** 061 * @see Socket#getSendBufferSize() 062 * 063 * @return the size of the send buffer 064 */ 065 int getSendBufferSize(); 066 067 /** 068 * @see Socket#setSendBufferSize(int) 069 * 070 * @param sendBufferSize The size of the send buffer 071 */ 072 void setSendBufferSize(int sendBufferSize); 073 074 /** 075 * @see Socket#getTrafficClass() 076 * 077 * @return the traffic class 078 */ 079 int getTrafficClass(); 080 081 /** 082 * @see Socket#setTrafficClass(int) 083 * 084 * @param trafficClass The traffic class to set, one of <tt>IPTOS_LOWCOST</tt> (0x02) 085 * <tt>IPTOS_RELIABILITY</tt> (0x04), <tt>IPTOS_THROUGHPUT</tt> (0x08) or <tt>IPTOS_LOWDELAY</tt> (0x10) 086 */ 087 void setTrafficClass(int trafficClass); 088 089 /** 090 * @see Socket#getKeepAlive() 091 * 092 * @return <tt>true</tt> if <tt>SO_KEEPALIVE</tt> is enabled. 093 */ 094 boolean isKeepAlive(); 095 096 /** 097 * @see Socket#setKeepAlive(boolean) 098 * 099 * @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}