public class DefaultSocketChannelConfig extends DefaultChannelConfig implements SocketChannelConfig
SocketChannelConfig
implementation.Modifier and Type | Field and Description |
---|---|
protected Socket |
javaSocket |
channel
Constructor and Description |
---|
DefaultSocketChannelConfig(SocketChannel channel,
Socket javaSocket)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
getOption(ChannelOption<T> option)
Return the value of the given
ChannelOption |
Map<ChannelOption<?>,Object> |
getOptions()
Return all set
ChannelOption 's. |
int |
getReceiveBufferSize()
Gets the
StandardSocketOptions.SO_RCVBUF option. |
int |
getSendBufferSize()
Gets the
StandardSocketOptions.SO_SNDBUF option. |
int |
getSoLinger()
Gets the
StandardSocketOptions.SO_LINGER option. |
int |
getTrafficClass()
Gets the
StandardSocketOptions.IP_TOS option. |
boolean |
isAllowHalfClosure()
Returns
true if and only if the channel should not close itself when its remote
peer shuts down output to make the connection half-closed. |
boolean |
isKeepAlive()
Gets the
StandardSocketOptions.SO_KEEPALIVE option. |
boolean |
isReuseAddress()
Gets the
StandardSocketOptions.SO_REUSEADDR option. |
boolean |
isTcpNoDelay()
Gets the
StandardSocketOptions.TCP_NODELAY option. |
SocketChannelConfig |
setAllocator(ByteBufAllocator allocator)
Set the
ByteBufAllocator which is used for the channel
to allocate buffers. |
SocketChannelConfig |
setAllowHalfClosure(boolean allowHalfClosure)
Sets whether the channel should not close itself when its remote peer shuts down output to
make the connection half-closed.
|
SocketChannelConfig |
setAutoClose(boolean autoClose) |
SocketChannelConfig |
setAutoRead(boolean autoRead)
Sets if
ChannelHandlerContext.read() will be invoked automatically so that a user application doesn't
need to call it at all. |
SocketChannelConfig |
setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the connect timeout of the channel in milliseconds.
|
SocketChannelConfig |
setKeepAlive(boolean keepAlive)
Sets the
StandardSocketOptions.SO_KEEPALIVE option. |
SocketChannelConfig |
setMaxMessagesPerRead(int maxMessagesPerRead)
Deprecated.
|
SocketChannelConfig |
setMessageSizeEstimator(MessageSizeEstimator estimator)
Set the
MessageSizeEstimator which is used for the channel
to detect the size of a message. |
<T> boolean |
setOption(ChannelOption<T> option,
T value)
Sets a configuration property with the specified name and value.
|
SocketChannelConfig |
setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
Sets the performance preferences as specified in
Socket.setPerformancePreferences(int, int, int) . |
SocketChannelConfig |
setReceiveBufferSize(int receiveBufferSize)
Sets the
StandardSocketOptions.SO_RCVBUF option. |
SocketChannelConfig |
setRecvByteBufAllocator(RecvByteBufAllocator allocator)
Set the
RecvByteBufAllocator which is used for the channel to allocate receive buffers. |
SocketChannelConfig |
setReuseAddress(boolean reuseAddress)
Sets the
StandardSocketOptions.SO_REUSEADDR option. |
SocketChannelConfig |
setSendBufferSize(int sendBufferSize)
Sets the
StandardSocketOptions.SO_SNDBUF option. |
SocketChannelConfig |
setSoLinger(int soLinger)
Sets the
StandardSocketOptions.SO_LINGER option. |
SocketChannelConfig |
setTcpNoDelay(boolean tcpNoDelay)
Sets the
StandardSocketOptions.TCP_NODELAY option. |
SocketChannelConfig |
setTrafficClass(int trafficClass)
Sets the
StandardSocketOptions.IP_TOS option. |
SocketChannelConfig |
setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
Sets the high water mark of the write buffer.
|
SocketChannelConfig |
setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
Sets the low water mark of the write buffer.
|
SocketChannelConfig |
setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
Set the
WriteBufferWaterMark which is used for setting the high and low
water mark of the write buffer. |
SocketChannelConfig |
setWriteSpinCount(int writeSpinCount)
Sets the maximum loop count for a write operation until
WritableByteChannel.write(ByteBuffer) returns a non-zero value. |
autoReadCleared, getAllocator, getConnectTimeoutMillis, getMaxMessagesPerRead, getMessageSizeEstimator, getOptions, getRecvByteBufAllocator, getWriteBufferHighWaterMark, getWriteBufferLowWaterMark, getWriteBufferWaterMark, getWriteSpinCount, isAutoClose, isAutoRead, setOptions, validate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAllocator, getConnectTimeoutMillis, getMaxMessagesPerRead, getMessageSizeEstimator, getRecvByteBufAllocator, getWriteBufferHighWaterMark, getWriteBufferLowWaterMark, getWriteBufferWaterMark, getWriteSpinCount, isAutoClose, isAutoRead, setOptions
protected final Socket javaSocket
public DefaultSocketChannelConfig(SocketChannel channel, Socket javaSocket)
public Map<ChannelOption<?>,Object> getOptions()
ChannelConfig
ChannelOption
's.getOptions
in interface ChannelConfig
getOptions
in class DefaultChannelConfig
public <T> T getOption(ChannelOption<T> option)
ChannelConfig
ChannelOption
getOption
in interface ChannelConfig
getOption
in class DefaultChannelConfig
public <T> boolean setOption(ChannelOption<T> option, T value)
ChannelConfig
public boolean setOption(ChannelOption<T> option, T value) { if (super.setOption(option, value)) { return true; } if (option.equals(additionalOption)) { .... return true; } return false; }
setOption
in interface ChannelConfig
setOption
in class DefaultChannelConfig
true
if and only if the property has been setpublic int getReceiveBufferSize()
SocketChannelConfig
StandardSocketOptions.SO_RCVBUF
option.getReceiveBufferSize
in interface SocketChannelConfig
public int getSendBufferSize()
SocketChannelConfig
StandardSocketOptions.SO_SNDBUF
option.getSendBufferSize
in interface SocketChannelConfig
public int getSoLinger()
SocketChannelConfig
StandardSocketOptions.SO_LINGER
option.getSoLinger
in interface SocketChannelConfig
public int getTrafficClass()
SocketChannelConfig
StandardSocketOptions.IP_TOS
option.getTrafficClass
in interface SocketChannelConfig
public boolean isKeepAlive()
SocketChannelConfig
StandardSocketOptions.SO_KEEPALIVE
option.isKeepAlive
in interface SocketChannelConfig
public boolean isReuseAddress()
SocketChannelConfig
StandardSocketOptions.SO_REUSEADDR
option.isReuseAddress
in interface SocketChannelConfig
public boolean isTcpNoDelay()
SocketChannelConfig
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
.isTcpNoDelay
in interface SocketChannelConfig
public SocketChannelConfig setKeepAlive(boolean keepAlive)
SocketChannelConfig
StandardSocketOptions.SO_KEEPALIVE
option.setKeepAlive
in interface SocketChannelConfig
public SocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth)
SocketChannelConfig
Socket.setPerformancePreferences(int, int, int)
.setPerformancePreferences
in interface SocketChannelConfig
public SocketChannelConfig setReceiveBufferSize(int receiveBufferSize)
SocketChannelConfig
StandardSocketOptions.SO_RCVBUF
option.setReceiveBufferSize
in interface SocketChannelConfig
public SocketChannelConfig setReuseAddress(boolean reuseAddress)
SocketChannelConfig
StandardSocketOptions.SO_REUSEADDR
option.setReuseAddress
in interface SocketChannelConfig
public SocketChannelConfig setSendBufferSize(int sendBufferSize)
SocketChannelConfig
StandardSocketOptions.SO_SNDBUF
option.setSendBufferSize
in interface SocketChannelConfig
public SocketChannelConfig setSoLinger(int soLinger)
SocketChannelConfig
StandardSocketOptions.SO_LINGER
option.setSoLinger
in interface SocketChannelConfig
public SocketChannelConfig setTcpNoDelay(boolean tcpNoDelay)
SocketChannelConfig
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
.setTcpNoDelay
in interface SocketChannelConfig
public SocketChannelConfig setTrafficClass(int trafficClass)
SocketChannelConfig
StandardSocketOptions.IP_TOS
option.setTrafficClass
in interface SocketChannelConfig
public boolean isAllowHalfClosure()
SocketChannelConfig
true
if and only if the channel should not close itself when its remote
peer shuts down output to make the connection half-closed. If false
, the connection
is closed automatically when the remote peer shuts down output.isAllowHalfClosure
in interface SocketChannelConfig
public SocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure)
SocketChannelConfig
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.setAllowHalfClosure
in interface SocketChannelConfig
public SocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
ChannelConfig
Channel
does not support connect operation, this property is not
used at all, and therefore will be ignored.setConnectTimeoutMillis
in interface ChannelConfig
setConnectTimeoutMillis
in interface SocketChannelConfig
setConnectTimeoutMillis
in class DefaultChannelConfig
connectTimeoutMillis
- the connect timeout in milliseconds.
0
to disable.@Deprecated public SocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)
DefaultChannelConfig
setMaxMessagesPerRead
in interface ChannelConfig
setMaxMessagesPerRead
in interface SocketChannelConfig
setMaxMessagesPerRead
in class DefaultChannelConfig
public SocketChannelConfig setWriteSpinCount(int writeSpinCount)
ChannelConfig
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
.setWriteSpinCount
in interface ChannelConfig
setWriteSpinCount
in interface SocketChannelConfig
setWriteSpinCount
in class DefaultChannelConfig
public SocketChannelConfig setAllocator(ByteBufAllocator allocator)
ChannelConfig
ByteBufAllocator
which is used for the channel
to allocate buffers.setAllocator
in interface ChannelConfig
setAllocator
in interface SocketChannelConfig
setAllocator
in class DefaultChannelConfig
public SocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)
ChannelConfig
RecvByteBufAllocator
which is used for the channel to allocate receive buffers.setRecvByteBufAllocator
in interface ChannelConfig
setRecvByteBufAllocator
in interface SocketChannelConfig
setRecvByteBufAllocator
in class DefaultChannelConfig
public SocketChannelConfig setAutoRead(boolean autoRead)
ChannelConfig
ChannelHandlerContext.read()
will be invoked automatically so that a user application doesn't
need to call it at all. The default value is true
.setAutoRead
in interface ChannelConfig
setAutoRead
in interface SocketChannelConfig
setAutoRead
in class DefaultChannelConfig
public SocketChannelConfig setAutoClose(boolean autoClose)
setAutoClose
in interface ChannelConfig
setAutoClose
in interface SocketChannelConfig
setAutoClose
in class DefaultChannelConfig
public SocketChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
ChannelConfig
Sets the high water mark of the write buffer. If the number of bytes
queued in the write buffer exceeds this value, Channel.isWritable()
will start to return false
.
setWriteBufferHighWaterMark
in interface ChannelConfig
setWriteBufferHighWaterMark
in class DefaultChannelConfig
public SocketChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
ChannelConfig
Sets the low water mark of the write buffer. Once the number of bytes
queued in the write buffer exceeded the
high water mark and then
dropped down below this value, Channel.isWritable()
will start to return
true
again.
setWriteBufferLowWaterMark
in interface ChannelConfig
setWriteBufferLowWaterMark
in class DefaultChannelConfig
public SocketChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
ChannelConfig
WriteBufferWaterMark
which is used for setting the high and low
water mark of the write buffer.setWriteBufferWaterMark
in interface ChannelConfig
setWriteBufferWaterMark
in interface SocketChannelConfig
setWriteBufferWaterMark
in class DefaultChannelConfig
public SocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)
ChannelConfig
MessageSizeEstimator
which is used for the channel
to detect the size of a message.setMessageSizeEstimator
in interface ChannelConfig
setMessageSizeEstimator
in interface SocketChannelConfig
setMessageSizeEstimator
in class DefaultChannelConfig
Copyright © 2008–2017 The Netty Project. All rights reserved.