0

我正在使用 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);
4

1 回答 1

0

没关系...通常您使用每个频道的 ChannelConfig 和所有频道的 Bootstrap。

于 2013-06-21T14:16:22.480 回答