我已将"receiveBufferSize"选项设置为1024,但由于某种原因,我仍然只在messageReceived中获得768个字节.数据的标题指示正在发送的数据的大小是1004.
以下是服务器的初始化代码:
public static void main(String[] args) throws Exception {
ConnectionlessBootstrap b = new ConnectionlessBootstrap(new NioDatagramChannelFactory());
// Options for a new channel
b.setOption("receiveBufferSize", 1024);
System.out.println(b.getOptions());
b.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(
new MyUDPPacketDecoder(),
new StdOutPrintHandler());
}
});
b.bind(new InetSocketAddress(myPort));
}
Run Code Online (Sandbox Code Playgroud)