TCP/IP で他の IP (ナビゲーション デバイス) からフル パケットを受信する必要があります。たとえば、デバイスは定期的に (1 分間で) 966 バイトを送信する必要があります。私の場合、最初に受信したバッファの長さは 256 バイト (パケットの最初の部分)、2 番目は 710 バイト (パケットの最後の部分)、3 番目は完全なパケット (966 バイト) です。最初に受信したバッファ長の最小値を手動で設定する方法は?
これは私のコードの一部です:
Executor bossExecutors = Executors.newCachedThreadPool();
Executor workerExecutors = Executors.newCachedThreadPool();
NioServerSocketChannelFactory channelsFactory =
new NioServerSocketChannelFactory(bossExecutors, workerExecutors);
ServerBootstrap bootstrap = new ServerBootstrap(channelsFactory);
ChannelPipelineFactory pipelineFactory = new NettyServerPipelineFactory(this.HWController);
bootstrap.setPipelineFactory(pipelineFactory);
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
bootstrap.setOption("child.receiveBufferSizePredictorFactory",
new FixedReceiveBufferSizePredictorFactory(2048)
);
bootstrap.bind(new InetSocketAddress(this.port));