Java Multicast Time To Live is always 0

2019-01-15 18:31发布

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

2条回答
贼婆χ
2楼-- · 2019-01-15 19:13

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
查看更多
神经病院院长
3楼-- · 2019-01-15 19:20

To implement pfranza's fix in Oracle, where you don't have a command line:

Set the property java.net.preferIPv4Stack=true in each Oracle session as follows before calling the java code containing the multicast call with the following PL/SQL snippet:

ret := dbms_java.set_property('java.net.preferIPv4Stack','true');

If the call is successful it will return NULL.

查看更多
登录 后发表回答