public class DefaultSocketChannelConfig extends DefaultChannelConfig implements SocketChannelConfig
SocketChannelConfig实现。
| Modifier and Type | Field and Description |
|---|---|
protected java.net.Socket |
javaSocket |
channel| Constructor and Description |
|---|
DefaultSocketChannelConfig(SocketChannel channel, java.net.Socket javaSocket)
创建一个新的实例。
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
getOption(ChannelOption<T> option)
返回给定的 ChannelOption的值
|
java.util.Map<ChannelOption<?>,java.lang.Object> |
getOptions()
返回所有设置 ChannelOption的。
|
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以检测消息的大小。
|
<T> boolean |
setOption(ChannelOption<T> option, T value)
使用指定的名称和值设置配置属性。
|
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 |
setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
设置写入缓冲区的高位标记。
|
SocketChannelConfig |
setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
设置写入缓冲区的低水位标志。
|
SocketChannelConfig |
setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
设置 WriteBufferWaterMark ,用于设置写入缓冲区的高位和低位水印。
|
SocketChannelConfig |
setWriteSpinCount(int writeSpinCount)
设置写操作的最大循环计数,直到
WritableByteChannel.write(ByteBuffer)返回非零值。
|
autoReadCleared, getAllocator, getConnectTimeoutMillis, getMaxMessagesPerRead, getMessageSizeEstimator, getOptions, getRecvByteBufAllocator, getWriteBufferHighWaterMark, getWriteBufferLowWaterMark, getWriteBufferWaterMark, getWriteSpinCount, isAutoClose, isAutoRead, setOptions, validateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllocator, getConnectTimeoutMillis, getMaxMessagesPerRead, getMessageSizeEstimator, getRecvByteBufAllocator, getWriteBufferHighWaterMark, getWriteBufferLowWaterMark, getWriteBufferWaterMark, getWriteSpinCount, isAutoClose, isAutoRead, setOptionspublic DefaultSocketChannelConfig(SocketChannel channel, java.net.Socket javaSocket)
public java.util.Map<ChannelOption<?>,java.lang.Object> getOptions()
ChannelConfig复制的描述
ChannelOption的。
getOptions在界面
ChannelConfig
getOptions
DefaultChannelConfig
public <T> T getOption(ChannelOption<T> option)
ChannelConfig
ChannelOption的值
getOption ,界面
ChannelConfig
getOption在类
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 ,界面
ChannelConfig
setOption在课堂上
DefaultChannelConfig
true当且仅当该属性已设置
public int getReceiveBufferSize()
SocketChannelConfig
StandardSocketOptions.SO_RCVBUF选项。
getReceiveBufferSize接口
SocketChannelConfig
public int getSendBufferSize()
SocketChannelConfig
StandardSocketOptions.SO_SNDBUF选项。
getSendBufferSize在界面
SocketChannelConfig
public int getSoLinger()
SocketChannelConfig
StandardSocketOptions.SO_LINGER选项。
getSoLinger在界面
SocketChannelConfig
public int getTrafficClass()
SocketChannelConfig
StandardSocketOptions.IP_TOS选项。
getTrafficClass接口
SocketChannelConfig
public boolean isKeepAlive()
SocketChannelConfig复制的描述
StandardSocketOptions.SO_KEEPALIVE选项。
isKeepAlive在界面
SocketChannelConfig
public boolean isReuseAddress()
SocketChannelConfig复制的描述
StandardSocketOptions.SO_REUSEADDR选项。
isReuseAddress在界面
SocketChannelConfig
public boolean isTcpNoDelay()
SocketChannelConfig
StandardSocketOptions.TCP_NODELAY选项。
请注意,这个选项的默认值是true不同于操作系统默认( false )。
但是,对于一些有问题的平台,例如Android,在Nagle算法禁用的情况下显示不稳定的行为,默认值仍为false 。
isTcpNoDelay ,界面
SocketChannelConfig
public SocketChannelConfig setKeepAlive(boolean keepAlive)
SocketChannelConfig复制的描述
StandardSocketOptions.SO_KEEPALIVE选项。
setKeepAlive接口
SocketChannelConfig
public SocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth)
SocketChannelConfig复制的描述
Socket.setPerformancePreferences(int, int, int)指定的性能首选项。
setPerformancePreferences接口
SocketChannelConfig
public SocketChannelConfig setReceiveBufferSize(int receiveBufferSize)
SocketChannelConfig
StandardSocketOptions.SO_RCVBUF选项。
setReceiveBufferSize在界面
SocketChannelConfig
public SocketChannelConfig setReuseAddress(boolean reuseAddress)
SocketChannelConfig复制的描述
StandardSocketOptions.SO_REUSEADDR选项。
setReuseAddress ,界面
SocketChannelConfig
public SocketChannelConfig setSendBufferSize(int sendBufferSize)
SocketChannelConfig
StandardSocketOptions.SO_SNDBUF选项。
setSendBufferSize在界面
SocketChannelConfig
public SocketChannelConfig setSoLinger(int soLinger)
SocketChannelConfig复制的描述
StandardSocketOptions.SO_LINGER选项。
setSoLinger在界面
SocketChannelConfig
public SocketChannelConfig setTcpNoDelay(boolean tcpNoDelay)
SocketChannelConfig复制的描述
StandardSocketOptions.TCP_NODELAY选项。
请注意,此选项的默认值是true与操作系统默认值( false )不同。
但是,对于一些有问题的平台,如Android,在Nagle算法禁用的情况下显示出不稳定的行为,默认值仍为false 。
setTcpNoDelay在界面
SocketChannelConfig
public SocketChannelConfig setTrafficClass(int trafficClass)
SocketChannelConfig
StandardSocketOptions.IP_TOS选项。
setTrafficClass在界面
SocketChannelConfig
public boolean isAllowHalfClosure()
SocketChannelConfig复制的描述
true当且仅当其远程对等关闭输出以使连接半闭时,通道不应关闭。
如果是false ,则当远程对等关闭输出时,连接会自动关闭。
isAllowHalfClosure接口
SocketChannelConfig
public SocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure)
SocketChannelConfig
true在远程对等关闭输出时连接未关闭。
相反, ChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)调用一个ChannelInputShutdownEvent对象。
如果false ,连接自动关闭。
setAllowHalfClosure ,界面
SocketChannelConfig
public SocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
ChannelConfig
Channel不支持连接操作,则完全不使用此属性,因此将被忽略。
setConnectTimeoutMillis ,界面
ChannelConfig
setConnectTimeoutMillis ,界面
SocketChannelConfig
setConnectTimeoutMillis在课堂上
DefaultChannelConfig
connectTimeoutMillis - 以毫秒为单位的连接超时。
0禁用。
@Deprecated public SocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)
DefaultChannelConfig
setMaxMessagesPerRead接口
ChannelConfig
setMaxMessagesPerRead在界面
SocketChannelConfig
setMaxMessagesPerRead
DefaultChannelConfig
public SocketChannelConfig setWriteSpinCount(int writeSpinCount)
ChannelConfig复制的描述
WritableByteChannel.write(ByteBuffer)返回非零值。
它类似于在并发编程中使用自旋锁。
它可以提高内存利用率并根据运行JVM的平台来编写吞吐量。
默认值是16 。
setWriteSpinCount在界面
ChannelConfig
setWriteSpinCount在界面
SocketChannelConfig
setWriteSpinCount
DefaultChannelConfig
public SocketChannelConfig setAllocator(ByteBufAllocator allocator)
ChannelConfig
ByteBufAllocator 。
setAllocator在界面
ChannelConfig
setAllocator在界面
SocketChannelConfig
setAllocator在类
DefaultChannelConfig
public SocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)
ChannelConfig
RecvByteBufAllocator 。
setRecvByteBufAllocator接口
ChannelConfig
setRecvByteBufAllocator在界面
SocketChannelConfig
setRecvByteBufAllocator在
DefaultChannelConfig
public SocketChannelConfig setAutoRead(boolean autoRead)
ChannelConfig复制的描述
ChannelHandlerContext.read(),以便用户应用程序根本不需要调用它。
默认值是true 。
setAutoRead在界面
ChannelConfig
setAutoRead在界面
SocketChannelConfig
setAutoRead
DefaultChannelConfig
public SocketChannelConfig setAutoClose(boolean autoClose)
setAutoClose ,界面
ChannelConfig
setAutoClose接口
SocketChannelConfig
setAutoClose在课堂上
DefaultChannelConfig
public SocketChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
ChannelConfig
设置写入缓冲区的高位标记。 如果写缓冲区中排队的字节数超过此值,则Channel.isWritable()将开始返回false 。
setWriteBufferHighWaterMark在界面
ChannelConfig
setWriteBufferHighWaterMark在课堂上
DefaultChannelConfig
public SocketChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
ChannelConfig
设置写入缓冲区的低水位标志。 一旦写入缓冲器中排队的字节数超过了high water mark ,然后下降到该值以下, Channel.isWritable()将再次开始返回true 。
setWriteBufferLowWaterMark在界面
ChannelConfig
setWriteBufferLowWaterMark在课堂上
DefaultChannelConfig
public SocketChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
ChannelConfig复制的描述
WriteBufferWaterMark ,用于设置写入缓冲区的高位和低位水印。
setWriteBufferWaterMark ,界面
ChannelConfig
setWriteBufferWaterMark在界面
SocketChannelConfig
setWriteBufferWaterMark在课堂上
DefaultChannelConfig
public SocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)
ChannelConfig复制的描述
MessageSizeEstimator以检测消息的大小。
setMessageSizeEstimator在界面
ChannelConfig
setMessageSizeEstimator在界面
SocketChannelConfig
setMessageSizeEstimator
DefaultChannelConfig
Copyright © 2008–2018 The Netty Project. All rights reserved.