.option(ChannelOption.SO_SNDBUF, options.sndbuf())
.option(ChannelOption.SO_REUSEADDR, options.reuseAddr())
.channelFactory(new ChannelFactory<Channel>() {
@Override
public Channel newChannel() {
final NioDatagramChannel ch = new NioDatagramChannel();
DatagramChannelConfig config = ch.config();
config.setReceiveBufferSize(options.rcvbuf());
config.setSendBufferSize(options.sndbuf());
config.setReuseAddress(options.reuseAddr());
if (null != multicastInterface) {
config.setNetworkInterface(multicastInterface);
}
if (null != nettyOptions && null != nettyOptions.pipelineConfigurer()) {
nettyOptions.pipelineConfigurer().accept(ch.pipeline());
}
ch.closeFuture().addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (log.isInfoEnabled()) {
log.info("CLOSE {}", ch);
}
close(ch);
}
});
netChannel = (NettyNetChannel<IN, OUT>) select(ch);
inboundHandler.setNetChannel(netChannel);
ch.pipeline().addLast(new ChannelOutboundHandlerAdapter() {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
super.write(ctx, msg, promise);
}
});