public interface SocketChannelConfig extends ChannelConfig
ChannelConfig为SocketChannel 。
ChannelConfig提供的选项外 , SocketChannelConfig还允许在选项图中使用以下选项:
Name Associated setter method ChannelOption.SO_KEEPALIVE setKeepAlive(boolean) ChannelOption.SO_REUSEADDR setReuseAddress(boolean) ChannelOption.SO_LINGER setSoLinger(int) ChannelOption.TCP_NODELAY setTcpNoDelay(boolean) ChannelOption.SO_RCVBUF setReceiveBufferSize(int) ChannelOption.SO_SNDBUF setSendBufferSize(int) ChannelOption.IP_TOS setTrafficClass(int) ChannelOption.ALLOW_HALF_CLOSURE setAllowHalfClosure(boolean)
| Modifier and Type | Method and Description |
|---|---|
int |
getReceiveBufferSize()
获取
StandardSocketOptions.SO_RCVBUF选项。
|
int |
getSendBufferSize()
获取
StandardSocketOptions.SO_SNDBUF选项。
|
int |
getSoLinger()
获取
StandardSocketOptions.SO_LINGER选项。
|
int |
getTrafficClass()
获取
StandardSocketOptions.IP_TOS选项。
|
boolean |
isAllowHalfClosure()
返回
true当且仅当其远程对等关闭输出以使连接半关闭时,通道不应该关闭。
|
boolean |
isKeepAlive()
获取
StandardSocketOptions.SO_KEEPALIVE选项。
|
boolean |
isReuseAddress()
获取
StandardSocketOptions.SO_REUSEADDR选项。
|
boolean |
isTcpNoDelay()
获取
StandardSocketOptions.TCP_NODELAY选项。
|
SocketChannelConfig |
setAllocator(ByteBufAllocator allocator)
设置用于通道分配缓冲区的 ByteBufAllocator 。
|
SocketChannelConfig |
setAllowHalfClosure(boolean allowHalfClosure)
设置当远程对等关闭输出以使连接半关闭时,通道是否应该关闭。
|
SocketChannelConfig |
setAutoClose(boolean autoClose) |
SocketChannelConfig |
setAutoRead(boolean autoRead)
设置是否自动调用
ChannelHandlerContext.read(),以便用户应用程序根本不需要调用它。
|
SocketChannelConfig |
setConnectTimeoutMillis(int connectTimeoutMillis)
以毫秒为单位设置通道的连接超时。
|
SocketChannelConfig |
setKeepAlive(boolean keepAlive)
设置
StandardSocketOptions.SO_KEEPALIVE选项。
|
SocketChannelConfig |
setMaxMessagesPerRead(int maxMessagesPerRead)
已过时。
|
SocketChannelConfig |
setMessageSizeEstimator(MessageSizeEstimator estimator)
设置用于通道的 MessageSizeEstimator以检测消息的大小。
|
SocketChannelConfig |
setPerformancePreferences(int connectionTime, int latency, int bandwidth)
设置
Socket.setPerformancePreferences(int, int, int)指定的性能首选项。
|
SocketChannelConfig |
setReceiveBufferSize(int receiveBufferSize)
设置
StandardSocketOptions.SO_RCVBUF选项。
|
SocketChannelConfig |
setRecvByteBufAllocator(RecvByteBufAllocator allocator)
设置用于通道分配接收缓冲区的 RecvByteBufAllocator 。
|
SocketChannelConfig |
setReuseAddress(boolean reuseAddress)
设置
StandardSocketOptions.SO_REUSEADDR选项。
|
SocketChannelConfig |
setSendBufferSize(int sendBufferSize)
设置
StandardSocketOptions.SO_SNDBUF选项。
|
SocketChannelConfig |
setSoLinger(int soLinger)
设置
StandardSocketOptions.SO_LINGER选项。
|
SocketChannelConfig |
setTcpNoDelay(boolean tcpNoDelay)
设置
StandardSocketOptions.TCP_NODELAY选项。
|
SocketChannelConfig |
setTrafficClass(int trafficClass)
设置
StandardSocketOptions.IP_TOS选项。
|
SocketChannelConfig |
setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
设置用于设置写入缓冲区的高位和低位水位的 WriteBufferWaterMark 。
|
SocketChannelConfig |
setWriteSpinCount(int writeSpinCount)
设置写入操作的最大循环数,直到
WritableByteChannel.write(ByteBuffer)返回非零值。
|
getAllocator, getConnectTimeoutMillis, getMaxMessagesPerRead, getMessageSizeEstimator, getOption, getOptions, getRecvByteBufAllocator, getWriteBufferHighWaterMark, getWriteBufferLowWaterMark, getWriteBufferWaterMark, getWriteSpinCount, isAutoClose, isAutoRead, setOption, setOptions, setWriteBufferHighWaterMark, setWriteBufferLowWaterMarkboolean isTcpNoDelay()
StandardSocketOptions.TCP_NODELAY选项。
请注意,此选项的默认值是true与操作系统默认值( false )不同。
但是,对于一些有问题的平台,例如Android,在Nagle算法禁用的情况下显示不稳定的行为,默认值仍为false 。
SocketChannelConfig setTcpNoDelay(boolean tcpNoDelay)
StandardSocketOptions.TCP_NODELAY选项。
请注意,这个选项的默认值是true不同于操作系统默认( false )。
但是,对于一些有问题的平台,如Android,在Nagle算法禁用的情况下显示不稳定的行为,默认值仍然为false 。
int getSoLinger()
StandardSocketOptions.SO_LINGER选项。
SocketChannelConfig setSoLinger(int soLinger)
StandardSocketOptions.SO_LINGER选项。
int getSendBufferSize()
StandardSocketOptions.SO_SNDBUF选项。
SocketChannelConfig setSendBufferSize(int sendBufferSize)
StandardSocketOptions.SO_SNDBUF选项。
int getReceiveBufferSize()
StandardSocketOptions.SO_RCVBUF选项。
SocketChannelConfig setReceiveBufferSize(int receiveBufferSize)
StandardSocketOptions.SO_RCVBUF选项。
boolean isKeepAlive()
StandardSocketOptions.SO_KEEPALIVE选项。
SocketChannelConfig setKeepAlive(boolean keepAlive)
StandardSocketOptions.SO_KEEPALIVE选项。
int getTrafficClass()
StandardSocketOptions.IP_TOS选项。
SocketChannelConfig setTrafficClass(int trafficClass)
StandardSocketOptions.IP_TOS选项。
boolean isReuseAddress()
StandardSocketOptions.SO_REUSEADDR选项。
SocketChannelConfig setReuseAddress(boolean reuseAddress)
StandardSocketOptions.SO_REUSEADDR选项。
SocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth)
Socket.setPerformancePreferences(int, int, int)规定设置性能首选项。
boolean isAllowHalfClosure()
true当且仅当其远程对等关闭输出以使连接半关闭时,通道不应关闭。
如果是false ,则当远程对等关闭输出时,连接会自动关闭。
SocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure)
true远程对等关闭输出,则连接未关闭。
相反, ChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)调用一个ChannelInputShutdownEvent对象。
如果false ,连接自动关闭。
SocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
ChannelConfig
Channel不支持连接操作,则完全不使用此属性,因此将被忽略。
setConnectTimeoutMillis ,界面
ChannelConfig
connectTimeoutMillis - 以毫秒为单位的连接超时。
0禁用。
@Deprecated SocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)
setMaxMessagesPerRead在界面
ChannelConfig
SocketChannelConfig setWriteSpinCount(int writeSpinCount)
ChannelConfig
WritableByteChannel.write(ByteBuffer)返回非零值。
它类似于在并发编程中使用自旋锁。
它可以提高内存利用率并根据运行JVM的平台来编写吞吐量。
默认值是16 。
setWriteSpinCount在界面
ChannelConfig
SocketChannelConfig setAllocator(ByteBufAllocator allocator)
ChannelConfig
ByteBufAllocator 。
setAllocator在界面
ChannelConfig
SocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)
ChannelConfig
RecvByteBufAllocator 。
setRecvByteBufAllocator在界面
ChannelConfig
SocketChannelConfig setAutoRead(boolean autoRead)
ChannelConfig
ChannelHandlerContext.read(),以便用户应用程序根本不需要调用它。
默认值是true 。
setAutoRead在界面
ChannelConfig
SocketChannelConfig setAutoClose(boolean autoClose)
setAutoClose在界面
ChannelConfig
SocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)
ChannelConfig
MessageSizeEstimator以检测消息的大小。
setMessageSizeEstimator ,界面
ChannelConfig
SocketChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
ChannelConfig
WriteBufferWaterMark用于设置写入缓冲区的高位和低位水印。
setWriteBufferWaterMark在界面
ChannelConfig
Copyright © 2008–2018 The Netty Project. All rights reserved.