AutoDetectingServerConfig.java 文件源码

java
阅读 13 收藏 0 点赞 0 评论 0

项目:eborp 作者:
private DatagramChannel createReceiveChannel() throws IOException {
    final String nicName = properties.getProperty(PropertiesReader.NETWORK_INTERFACE);
    final NetworkInterface networkInterface = getNetworkInterface(nicName);

    final DatagramChannel channel = DatagramChannel.open(StandardProtocolFamily.INET);
    channel.setOption(StandardSocketOptions.SO_REUSEADDR, true)
            .bind(new InetSocketAddress(ANNOUNCE_PORT))
            .setOption(StandardSocketOptions.IP_MULTICAST_IF, networkInterface);

    final InetAddress group = InetAddress.getByName(MULTICAST_GROUP);
    channel.join(group, networkInterface);

    return channel;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号