Package io.netty.channel.socket
Interface SocketChannelConfig
-
- All Superinterfaces:
ChannelConfig,DuplexChannelConfig
- All Known Subinterfaces:
OioSocketChannelConfig
- All Known Implementing Classes:
DefaultOioSocketChannelConfig,DefaultSocketChannelConfig,EpollSocketChannelConfig,KQueueSocketChannelConfig
public interface SocketChannelConfig extends DuplexChannelConfig
AChannelConfigfor aSocketChannel.Available options
In addition to the options provided byDuplexChannelConfig,SocketChannelConfigallows the following options in the option map:
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description intgetReceiveBufferSize()Gets theStandardSocketOptions.SO_RCVBUFoption.intgetSendBufferSize()Gets theStandardSocketOptions.SO_SNDBUFoption.intgetSoLinger()Gets theStandardSocketOptions.SO_LINGERoption.intgetTrafficClass()Gets theStandardSocketOptions.IP_TOSoption.booleanisKeepAlive()Gets theStandardSocketOptions.SO_KEEPALIVEoption.booleanisReuseAddress()Gets theStandardSocketOptions.SO_REUSEADDRoption.booleanisTcpNoDelay()Gets theStandardSocketOptions.TCP_NODELAYoption.SocketChannelConfigsetAllocator(ByteBufAllocator allocator)Set theByteBufAllocatorwhich is used for the channel to allocate buffers.SocketChannelConfigsetAllowHalfClosure(boolean allowHalfClosure)Sets whether the channel should not close itself when its remote peer shuts down output to make the connection half-closed.SocketChannelConfigsetAutoClose(boolean autoClose)Sets whether theChannelshould be closed automatically and immediately on write failure.SocketChannelConfigsetAutoRead(boolean autoRead)Sets ifChannelHandlerContext.read()will be invoked automatically so that a user application doesn't need to call it at all.SocketChannelConfigsetConnectTimeoutMillis(int connectTimeoutMillis)Sets the connect timeout of the channel in milliseconds.SocketChannelConfigsetKeepAlive(boolean keepAlive)Sets theStandardSocketOptions.SO_KEEPALIVEoption.SocketChannelConfigsetMaxMessagesPerRead(int maxMessagesPerRead)Deprecated.SocketChannelConfigsetMessageSizeEstimator(MessageSizeEstimator estimator)Set theMessageSizeEstimatorwhich is used for the channel to detect the size of a message.SocketChannelConfigsetPerformancePreferences(int connectionTime, int latency, int bandwidth)Sets the performance preferences as specified inSocket.setPerformancePreferences(int, int, int).SocketChannelConfigsetReceiveBufferSize(int receiveBufferSize)Sets theStandardSocketOptions.SO_RCVBUFoption.SocketChannelConfigsetRecvByteBufAllocator(RecvByteBufAllocator allocator)Set theRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.SocketChannelConfigsetReuseAddress(boolean reuseAddress)Sets theStandardSocketOptions.SO_REUSEADDRoption.SocketChannelConfigsetSendBufferSize(int sendBufferSize)Sets theStandardSocketOptions.SO_SNDBUFoption.SocketChannelConfigsetSoLinger(int soLinger)Sets theStandardSocketOptions.SO_LINGERoption.SocketChannelConfigsetTcpNoDelay(boolean tcpNoDelay)Sets theStandardSocketOptions.TCP_NODELAYoption.SocketChannelConfigsetTrafficClass(int trafficClass)Sets theStandardSocketOptions.IP_TOSoption.SocketChannelConfigsetWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)Set theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.SocketChannelConfigsetWriteSpinCount(int writeSpinCount)Sets the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)returns a non-zero value.-
Methods inherited from interface io.netty.channel.ChannelConfig
getAllocator, getConnectTimeoutMillis, getMaxMessagesPerRead, getMessageSizeEstimator, getOption, getOptions, getRecvByteBufAllocator, getWriteBufferHighWaterMark, getWriteBufferLowWaterMark, getWriteBufferWaterMark, getWriteSpinCount, isAutoClose, isAutoRead, setOption, setOptions, setWriteBufferHighWaterMark, setWriteBufferLowWaterMark
-
Methods inherited from interface io.netty.channel.socket.DuplexChannelConfig
isAllowHalfClosure
-
-
-
-
Method Detail
-
isTcpNoDelay
boolean isTcpNoDelay()
Gets theStandardSocketOptions.TCP_NODELAYoption. Please note that the default value of this option istrueunlike the operating system default (false). However, for some buggy platforms, such as Android, that shows erratic behavior with Nagle's algorithm disabled, the default value remains to befalse.
-
setTcpNoDelay
SocketChannelConfig setTcpNoDelay(boolean tcpNoDelay)
Sets theStandardSocketOptions.TCP_NODELAYoption. Please note that the default value of this option istrueunlike the operating system default (false). However, for some buggy platforms, such as Android, that shows erratic behavior with Nagle's algorithm disabled, the default value remains to befalse.
-
getSoLinger
int getSoLinger()
Gets theStandardSocketOptions.SO_LINGERoption.
-
setSoLinger
SocketChannelConfig setSoLinger(int soLinger)
Sets theStandardSocketOptions.SO_LINGERoption.
-
getSendBufferSize
int getSendBufferSize()
Gets theStandardSocketOptions.SO_SNDBUFoption.
-
setSendBufferSize
SocketChannelConfig setSendBufferSize(int sendBufferSize)
Sets theStandardSocketOptions.SO_SNDBUFoption.
-
getReceiveBufferSize
int getReceiveBufferSize()
Gets theStandardSocketOptions.SO_RCVBUFoption.
-
setReceiveBufferSize
SocketChannelConfig setReceiveBufferSize(int receiveBufferSize)
Sets theStandardSocketOptions.SO_RCVBUFoption.
-
isKeepAlive
boolean isKeepAlive()
Gets theStandardSocketOptions.SO_KEEPALIVEoption.
-
setKeepAlive
SocketChannelConfig setKeepAlive(boolean keepAlive)
Sets theStandardSocketOptions.SO_KEEPALIVEoption.
-
getTrafficClass
int getTrafficClass()
Gets theStandardSocketOptions.IP_TOSoption.
-
setTrafficClass
SocketChannelConfig setTrafficClass(int trafficClass)
Sets theStandardSocketOptions.IP_TOSoption.
-
isReuseAddress
boolean isReuseAddress()
Gets theStandardSocketOptions.SO_REUSEADDRoption.
-
setReuseAddress
SocketChannelConfig setReuseAddress(boolean reuseAddress)
Sets theStandardSocketOptions.SO_REUSEADDRoption.
-
setPerformancePreferences
SocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth)
Sets the performance preferences as specified inSocket.setPerformancePreferences(int, int, int).
-
setAllowHalfClosure
SocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure)
Description copied from interface:DuplexChannelConfigSets whether the channel should not close itself when its remote peer shuts down output to make the connection half-closed. Iftruethe connection is not closed when the remote peer shuts down output. Instead,ChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)is invoked with aChannelInputShutdownEventobject. Iffalse, the connection is closed automatically.- Specified by:
setAllowHalfClosurein interfaceDuplexChannelConfig
-
setConnectTimeoutMillis
SocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
Description copied from interface:ChannelConfigSets the connect timeout of the channel in milliseconds. If theChanneldoes not support connect operation, this property is not used at all, and therefore will be ignored.- Specified by:
setConnectTimeoutMillisin interfaceChannelConfig- Parameters:
connectTimeoutMillis- the connect timeout in milliseconds.0to disable.
-
setMaxMessagesPerRead
@Deprecated SocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)
Deprecated.- Specified by:
setMaxMessagesPerReadin interfaceChannelConfig- Specified by:
setMaxMessagesPerReadin interfaceDuplexChannelConfig
-
setWriteSpinCount
SocketChannelConfig setWriteSpinCount(int writeSpinCount)
Description copied from interface:ChannelConfigSets the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)returns a non-zero value. It is similar to what a spin lock is used for in concurrency programming. It improves memory utilization and write throughput depending on the platform that JVM runs on. The default value is16.- Specified by:
setWriteSpinCountin interfaceChannelConfig- Specified by:
setWriteSpinCountin interfaceDuplexChannelConfig
-
setAllocator
SocketChannelConfig setAllocator(ByteBufAllocator allocator)
Description copied from interface:ChannelConfigSet theByteBufAllocatorwhich is used for the channel to allocate buffers.- Specified by:
setAllocatorin interfaceChannelConfig- Specified by:
setAllocatorin interfaceDuplexChannelConfig
-
setRecvByteBufAllocator
SocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)
Description copied from interface:ChannelConfigSet theRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.- Specified by:
setRecvByteBufAllocatorin interfaceChannelConfig- Specified by:
setRecvByteBufAllocatorin interfaceDuplexChannelConfig
-
setAutoRead
SocketChannelConfig setAutoRead(boolean autoRead)
Description copied from interface:ChannelConfigSets ifChannelHandlerContext.read()will be invoked automatically so that a user application doesn't need to call it at all. The default value istrue.- Specified by:
setAutoReadin interfaceChannelConfig- Specified by:
setAutoReadin interfaceDuplexChannelConfig
-
setAutoClose
SocketChannelConfig setAutoClose(boolean autoClose)
Description copied from interface:ChannelConfigSets whether theChannelshould be closed automatically and immediately on write failure. The default istrue.- Specified by:
setAutoClosein interfaceChannelConfig- Specified by:
setAutoClosein interfaceDuplexChannelConfig
-
setMessageSizeEstimator
SocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)
Description copied from interface:ChannelConfigSet theMessageSizeEstimatorwhich is used for the channel to detect the size of a message.- Specified by:
setMessageSizeEstimatorin interfaceChannelConfig- Specified by:
setMessageSizeEstimatorin interfaceDuplexChannelConfig
-
setWriteBufferWaterMark
SocketChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
Description copied from interface:ChannelConfigSet theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.- Specified by:
setWriteBufferWaterMarkin interfaceChannelConfig- Specified by:
setWriteBufferWaterMarkin interfaceDuplexChannelConfig
-
-