背景问题
在使用rpc框架时,设置socket参数时会使用到下面的api:
soccket.setReceiveBufferSize()——设置接受数据的缓冲区大小
socket.setSendBufferSize()———-设置发送数据的缓冲区大小
[Read More]在使用rpc框架时,设置socket参数时会使用到下面的api:
soccket.setReceiveBufferSize()——设置接受数据的缓冲区大小
socket.setSendBufferSize()———-设置发送数据的缓冲区大小
[Read More]Netty在开发基于udp协议的代码中server段设置的参数broadcast有什么意义?
public static void initServer() {
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
.handler(new UdpServerHandler());
Channel channel = bootstrap.bind(AppConstants.SEARCH_PORT).sync().channel();
channel.closeFuture().await();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
group.shutdownGracefully();
}
}
设置SO_BROADCAST选项为0,只接受单播数据报 设置SO_BROADCASE选项为1,接受UDP广播