OpentrackerLiveSync.java 文件源码

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

项目:bt 作者:
@Override
public void start(Collection<DHT> dhts, ConfigReader config) {
    try {
        channel = DatagramChannel.open(StandardProtocolFamily.INET);
        channel.setOption(StandardSocketOptions.IP_MULTICAST_TTL, 1);
        channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        // we only need to send, not to receive, so need to bind to a specific port
        channel.bind(new InetSocketAddress(0));
        channel.connect(new InetSocketAddress(InetAddress.getByAddress(new byte[] {(byte) 224,0,23,5}), 9696));
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }

    t.setDaemon(true);
    t.setName("opentracker-sync");
    t.start();

    // OT-sync only supports ipv4 atm
    dhts.stream().filter(d -> d.getType().PREFERRED_ADDRESS_TYPE == Inet4Address.class).forEach(d -> {
        d.addIncomingMessageListener(this::incomingPacket);
    });

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号