netty中非阻塞通道中的SO_TIMEOUT

时间:2014-04-06 10:07:16

标签: netty

如果某个通道在超时毫秒内没有收到读取/响应,那么SO_TIMEOUT是否会使非阻塞通道失效?

bootstrap.group(workerGroup).channel(NioSocketChannel.class).
.handler(channelInitializer).option(ChannelOption.SO_TIMEOUT, 100);

此外,该选项是否也适用于服务器频道?像:

serverBootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).
localAddress(new InetSocketAddress(8800)).childHandler(serverChannelInitializer).
option(ChannelOption.SO_TIMEOUT, 100).bind().sync();

1 个答案:

答案 0 :(得分:8)

没有。 SO_TIMEOUT仅对OIO套接字传输有效。您应该使用IdleStateHandler并在IdleStateEvent实施中处理userEventTriggered()