Java control IP TTL?

后端 未结 2 676
傲寒
傲寒 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
    
    0 讨论(0)
  • 2020-12-21 06:08

    Apparently only on Multicast sockets, which have:

    MulticastSocket.setTimeToLive(int ttl);
    
    0 讨论(0)
提交回复
热议问题