我正在使用Netty 3.6.6 Final,我希望在UDP Netty IO Client实现中设置sendBufferSize和receiveBufferSize选项,ConnectionlessBootstrap setOption()和ChannelConfig setOption()之间有什么区别?我应该使用哪两种setOption方法,还是重要?
DatagramChannelFactory datagramChannelFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool());
ConnectionlessBootstrap connectionlessBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
connectionlessBootstrap.setPipelineFactory(...);
ChannelFuture channelFuture = connectionlessBootstrap.connect(new InetSocketAddress(host, port));
channelFuture.awaitUninterruptibly();
Channel channel = channelFuture.getChannel();
ChannelConfig channelConfig = channel.getConfig();
// Now, do this:
channelConfig.setOption("sendBufferSize", udpSendBufferSize);
channelConfig.setOption("receiveBufferSize", udpReceiveBufferSize);
// or do this:
connectionlessBootstrap.setOption("sendBufferSize", udpSendBufferSize);
connectionlessBootstrap.setOption("receiveBufferSize", udpReceiveBufferSize);
答案 0 :(得分:0)
没关系......通常你会为所有频道使用ChannelConfig per Channel和Bootstrap。