Top Description Methods
io.netty.channel.socket

public Interface SocketChannelConfig

extends DuplexChannelConfig
Known Direct Subinterfaces
io.netty.channel.socket.oio.OioSocketChannelConfig
Known Direct Implementers
io.netty.channel.socket.DefaultSocketChannelConfig
Imports
io.netty.buffer.ByteBufAllocator, io.netty.channel.ChannelConfig, .ChannelOption, .MessageSizeEstimator, .RecvByteBufAllocator, .WriteBufferWaterMark, java.net.Socket, .StandardSocketOptions

A ChannelConfig for a SocketChannel.

Available options

In addition to the options provided by DuplexChannelConfig, SocketChannelConfig allows the following options in the option map:
NameAssociated setter method
ChannelOption#SO_KEEPALIVEsetKeepAlive(boolean)
ChannelOption#SO_REUSEADDRsetReuseAddress(boolean)
ChannelOption#SO_LINGERsetSoLinger(int)
ChannelOption#TCP_NODELAYsetTcpNoDelay(boolean)
ChannelOption#SO_RCVBUFsetReceiveBufferSize(int)
ChannelOption#SO_SNDBUFsetSendBufferSize(int)
ChannelOption#IP_TOSsetTrafficClass(int)
ChannelOption#ALLOW_HALF_CLOSUREsetAllowHalfClosure(boolean)

Method Summary

Modifier and TypeMethod and Description
public int
public int
public int
public int
public boolean
public boolean
public boolean
public SocketChannelConfig
setAllocator(ByteBufAllocator allocator)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setAllocator.

Set the ByteBufAllocator which is used for the channel to allocate buffers.
public SocketChannelConfig
setAllowHalfClosure(boolean allowHalfClosure)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setAllowHalfClosure.

Sets whether the channel should not close itself when its remote peer shuts down output to make the connection half-closed.
public SocketChannelConfig
setAutoClose(boolean autoClose)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setAutoClose.

Sets whether the Channel should be closed automatically and immediately on write failure.
public SocketChannelConfig
setAutoRead(boolean autoRead)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setAutoRead.

Sets if ChannelHandlerContext#read() will be invoked automatically so that a user application doesn't need to call it at all.
public SocketChannelConfig
setConnectTimeoutMillis(int
the connect timeout in milliseconds. 0 to disable.
connectTimeoutMillis
)

Redeclares io.netty.channel.ChannelConfig.setConnectTimeoutMillis.

Sets the connect timeout of the channel in milliseconds.
public SocketChannelConfig
setKeepAlive(boolean keepAlive)

Sets the StandardSocketOptions#SO_KEEPALIVE option.

public SocketChannelConfig
public SocketChannelConfig
setMessageSizeEstimator(MessageSizeEstimator estimator)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setMessageSizeEstimator.

Set the MessageSizeEstimator which is used for the channel to detect the size of a message.
public SocketChannelConfig
setPerformancePreferences(int connectionTime, int latency, int bandwidth)

Sets the performance preferences as specified in Socket#setPerformancePreferences(int, int, int).

public SocketChannelConfig
setReceiveBufferSize(int receiveBufferSize)

Sets the StandardSocketOptions#SO_RCVBUF option.

public SocketChannelConfig
setRecvByteBufAllocator(RecvByteBufAllocator allocator)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setRecvByteBufAllocator.

Set the RecvByteBufAllocator which is used for the channel to allocate receive buffers.
public SocketChannelConfig
setReuseAddress(boolean reuseAddress)

Sets the StandardSocketOptions#SO_REUSEADDR option.

public SocketChannelConfig
setSendBufferSize(int sendBufferSize)

Sets the StandardSocketOptions#SO_SNDBUF option.

public SocketChannelConfig
setSoLinger(int soLinger)

Sets the StandardSocketOptions#SO_LINGER option.

public SocketChannelConfig
setTcpNoDelay(boolean tcpNoDelay)

Sets the StandardSocketOptions#TCP_NODELAY option.

public SocketChannelConfig
setTrafficClass(int trafficClass)

Sets the StandardSocketOptions#IP_TOS option.

public SocketChannelConfig
setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setWriteBufferWaterMark.

Set the WriteBufferWaterMark which is used for setting the high and low water mark of the write buffer.
public SocketChannelConfig
setWriteSpinCount(int writeSpinCount)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setWriteSpinCount.

Sets the maximum loop count for a write operation until WritableByteChannel#write(ByteBuffer) returns a non-zero value.
Inherited from io.netty.channel.socket.DuplexChannelConfig:
isAllowHalfClosure

Method Detail

getReceiveBufferSizeback to summary
public int getReceiveBufferSize()

Gets the StandardSocketOptions#SO_RCVBUF option.

getSendBufferSizeback to summary
public int getSendBufferSize()

Gets the StandardSocketOptions#SO_SNDBUF option.

getSoLingerback to summary
public int getSoLinger()

Gets the StandardSocketOptions#SO_LINGER option.

getTrafficClassback to summary
public int getTrafficClass()

Gets the StandardSocketOptions#IP_TOS option.

isKeepAliveback to summary
public boolean isKeepAlive()

Gets the StandardSocketOptions#SO_KEEPALIVE option.

isReuseAddressback to summary
public boolean isReuseAddress()

Gets the StandardSocketOptions#SO_REUSEADDR option.

isTcpNoDelayback to summary
public boolean isTcpNoDelay()

Gets the StandardSocketOptions#TCP_NODELAY option. Please note that the default value of this option is true unlike 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 be false.

setAllocatorback to summary
public SocketChannelConfig setAllocator(ByteBufAllocator allocator)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setAllocator.

Doc from io.netty.channel.ChannelConfig.setAllocator.

Set the ByteBufAllocator which is used for the channel to allocate buffers.

Annotations
@Override
setAllowHalfClosureback to summary
public SocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setAllowHalfClosure.

Doc from io.netty.channel.socket.DuplexChannelConfig.setAllowHalfClosure.

Sets whether the channel should not close itself when its remote peer shuts down output to make the connection half-closed. If true the connection is not closed when the remote peer shuts down output. Instead, ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object) is invoked with a ChannelInputShutdownEvent object. If false, the connection is closed automatically.

Annotations
@Override
setAutoCloseback to summary
public SocketChannelConfig setAutoClose(boolean autoClose)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setAutoClose.

Doc from io.netty.channel.ChannelConfig.setAutoClose.

Sets whether the Channel should be closed automatically and immediately on write failure. The default is true.

Annotations
@Override
setAutoReadback to summary
public SocketChannelConfig setAutoRead(boolean autoRead)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setAutoRead.

Doc from io.netty.channel.ChannelConfig.setAutoRead.

Sets if ChannelHandlerContext#read() will be invoked automatically so that a user application doesn't need to call it at all. The default value is true.

Annotations
@Override
setConnectTimeoutMillisback to summary
public SocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)

Redeclares io.netty.channel.ChannelConfig.setConnectTimeoutMillis.

Doc from io.netty.channel.ChannelConfig.setConnectTimeoutMillis.

Sets the connect timeout of the channel in milliseconds. If the Channel does not support connect operation, this property is not used at all, and therefore will be ignored.

Parameters
connectTimeoutMillis:int

the connect timeout in milliseconds. 0 to disable.

Annotations
@Override
setKeepAliveback to summary
public SocketChannelConfig setKeepAlive(boolean keepAlive)

Sets the StandardSocketOptions#SO_KEEPALIVE option.

setMaxMessagesPerReadback to summary
public SocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setMaxMessagesPerRead.

Deprecated

Annotations
@Override
@Deprecated
setMessageSizeEstimatorback to summary
public SocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setMessageSizeEstimator.

Doc from io.netty.channel.ChannelConfig.setMessageSizeEstimator.

Set the MessageSizeEstimator which is used for the channel to detect the size of a message.

Annotations
@Override
setPerformancePreferencesback to summary
public SocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth)

Sets the performance preferences as specified in Socket#setPerformancePreferences(int, int, int).

setReceiveBufferSizeback to summary
public SocketChannelConfig setReceiveBufferSize(int receiveBufferSize)

Sets the StandardSocketOptions#SO_RCVBUF option.

setRecvByteBufAllocatorback to summary
public SocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setRecvByteBufAllocator.

Doc from io.netty.channel.ChannelConfig.setRecvByteBufAllocator.

Set the RecvByteBufAllocator which is used for the channel to allocate receive buffers.

Annotations
@Override
setReuseAddressback to summary
public SocketChannelConfig setReuseAddress(boolean reuseAddress)

Sets the StandardSocketOptions#SO_REUSEADDR option.

setSendBufferSizeback to summary
public SocketChannelConfig setSendBufferSize(int sendBufferSize)

Sets the StandardSocketOptions#SO_SNDBUF option.

setSoLingerback to summary
public SocketChannelConfig setSoLinger(int soLinger)

Sets the StandardSocketOptions#SO_LINGER option.

setTcpNoDelayback to summary
public SocketChannelConfig setTcpNoDelay(boolean tcpNoDelay)

Sets the StandardSocketOptions#TCP_NODELAY option. Please note that the default value of this option is true unlike 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 be false.

setTrafficClassback to summary
public SocketChannelConfig setTrafficClass(int trafficClass)

Sets the StandardSocketOptions#IP_TOS option.

setWriteBufferWaterMarkback to summary
public SocketChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setWriteBufferWaterMark.

Doc from io.netty.channel.ChannelConfig.setWriteBufferWaterMark.

Set the WriteBufferWaterMark which is used for setting the high and low water mark of the write buffer.

Annotations
@Override
setWriteSpinCountback to summary
public SocketChannelConfig setWriteSpinCount(int writeSpinCount)

Redeclares io.netty.channel.socket.DuplexChannelConfig.setWriteSpinCount.

Doc from io.netty.channel.ChannelConfig.setWriteSpinCount.

Sets the maximum loop count for a write operation until WritableByteChannel#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 is 16.

Annotations
@Override