Hi Don,
Yes, in recent kernels (2.6.*), both IPv4 and IPv6 socket options can be
set for an IPv6 socket. And seems setting both of them is the only way
to make things like TTL/HOP_LIMIT works properly as expected.
Only that I still need to do more testing for different kernel versions.
Hope I can integrate the patch soon.
-Edward
Don Coleman wrote:
-Djava.net.preferIPv4Stack=true works fine for IPv4, but my
application needs to send both IPv4 and IPv6.
I'd be interested to see Edward Wang's patch for this issue.
On 6/1/07, Alan Bateman <[EMAIL PROTECTED]> wrote:
Don Coleman wrote:
> I'm have a problem setting TTL when sending Multicast packets to an
> IPv4 address over an IPv6 socket.
>
> Setting the TTL in Java has no effect when sending to an IPv4 address.
> It is always 1.
>
> This is only a problem on Linux, it works fine on OS X, Solaris and
> Windows.
>
> This problem exists with JDK5, but it looks like it's also in the JDK7
> code.
>
>
https://openjdk.dev.java.net/source/browse/openjdk/jdk/trunk/j2se/src/solaris/native/java/net/PlainDatagramSocketImpl.c?annotate=237
>
>
> on line 1873 IPV6_MULTICAST_HOPS is set
> for Linux I think we need also need to set IP_MULTICAST_TTL
>
> I've attached sample Java and C code that demonstrates the problem
> here https://bugs.launchpad.net/ubuntu/+bug/112257
>
> Any thoughts if this is a Java problem or a Linux kernel bug?
The bug tracking this one is:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6250763
At least in older kernels, it wasn't possible to set IPv4 multicast
options on IPv6 sockets (the setsockopt would fail). Edward Wang has
been testing with recent kernels and has results that suggest that
setting the IPv4 options work now. I believe he has a fix/patch in the
works to address this (Edward - can you comment?).
If you need a workaround then run with -Djava.net.preferIPv4Stack=true
so that all sockets are IPv4 (even if the machine has IPv6 enabled).
-Alan.