public void init(ChannelPipelineFactory factory) throws Exception
{
id = String.format("%1$020d",
Math.abs(new Random(System.currentTimeMillis()).nextLong()))
.getBytes();
group = new OioEventLoopGroup();
connectionlessBootstrap = new Bootstrap();
connectionlessBootstrap.group(group);
connectionlessBootstrap.option(ChannelOption.SO_BROADCAST, true);
connectionlessBootstrap.handler(factory);
connectionlessBootstrap.channel(OioDatagramChannel.class);
;
datagramChannel = (DatagramChannel) connectionlessBootstrap
.bind(new InetSocketAddress(mcastGroupPort)).sync().channel();
multicastAddress = new InetSocketAddress(mcastGroupIp, mcastGroupPort);
NetworkInterface networkInterface = NetworkInterface
.getByInetAddress(InetAddress.getByName(bindAddress));
// for (Enumeration nifs = NetworkInterface.getNetworkInterfaces();
// nifs.hasMoreElements(); )
datagramChannel.joinGroup(multicastAddress, null);// (NetworkInterface)
// nifs.nextElement());
init = true;
if (debug)
factory.debug();
}
MulticastEndpoint.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:yajsw
作者:
评论列表
文章目录