5
我已經將「receiveBufferSize」選項設置爲1024,但由於某種原因,我仍然只能在messageReceived中獲得768個字節。數據的頭指示發送的數據的大小是1004爲什麼Netty只給我發送來自UDP消息的768字節
下面是服務器的初始化代碼:
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));
}
你能添加引用默認預測是768字節固定大小的預測器? – eric 2013-02-05 02:45:22
[DatagramChannelFactory](http://static.netty.io/3.6/api/org/jboss/netty/channel/socket/DatagramChannelConfig.html)。查看setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)'_默認預測器是FixedReceiveBufferSizePredictor(768)_ – 2013-02-09 19:04:23