我正在使用 Netty 3.6.6 Final,我希望在 UDP Netty IO 客户端实现中设置 sendBufferSize 和 receiveBufferSize 选项,ConnectionlessBootstrap setOption() 和 ChannelConfig setOption() 有什么区别?我应该使用 2 种 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);