本文介绍了Java多播生存时间始终为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在设置数据报包上的TTL时遇到问题。我在将数据包发送到multicastSocket之前调用数据包上的setTTL(...)方法,但如果我使用ethereal捕获数据包,则TTL字段始终设置为0
I have a problem with setting the TTL on my Datagram packets. I am calling the setTTL(...) method on the packet before sending the packet to the multicastSocket but if I capture the packet with ethereal the TTL field is always set to 0
推荐答案
有趣的是你应该问这个,因为我只是,我在6个月前遇到了同样的问题。基本上你必须设置一个特殊的系统属性告诉JVM使用IPv4堆栈:
Funny that you should ask this, because I just wrote about this yesterday, I was having the same problem about 6 months ago. Basically you have to set an special system property telling the JVM to use an IPv4 stack:
-Djava.net.preferIPv4Stack=true
这篇关于Java多播生存时间始终为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!