ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap(
new OioDatagramChannelFactory(Executors.newCachedThreadPool()));
Channel channel = serverBootstrap.bind(new InetSocketAddress(port));
final ChannelConfig config = channel.getConfig();
DefaultDatagramChannelConfig channelConfig = (DefaultDatagramChannelConfig) config;
// 设置接收数据最大大小
channelConfig.setReceiveBufferSizePredictor(new FixedReceiveBufferSizePredictor(65535));
【netty】使用ConnectionlessBootstrap实现udp协议接收数据时,如果数据长度超过732会被丢弃
最新推荐文章于 2021-09-11 21:29:37 发布