Java control IP TTL?

后端 未结 2 679
傲寒
傲寒 2020-12-21 05:21

In Java, is there a way to control the TTL of the IP header for packets sent on a socket?

2条回答
  •  北海茫月
    2020-12-21 06:00

    Setting the TTL using

    MulticastSocket.setTimeToLive(int ttl);
    

    is only going to work if you have enabled the IPV4Stack as outlined by this other question

    Java Multicast Time To Live is always 0

    -Djava.net.preferIPv4Stack=true
    

提交回复
热议问题