MulticastSocket(group,port) problems with bind() with IPv6 enabled
pekkas at netcore.fi
Fri Dec 5 04:14:39 PST 2008
I've looked through the Sun bug database and AFAICS this is not
listed. I've also looked through the latest source code to see if
this is addressed , but apparently not. I'm trying to find a way
to get this addressed.
When you create a MulticastSocket(new InetSocketAddress(group, port))
with an IPv4 address as a string in 'group' on an IPv6-enabled system,
the socket is created as PF_INET6. This results in mapping the
address to mapped address format (e.g. "::ffff:220.127.116.11").
This also results in a bind() system call to the ipv6 mapped address.
On Linux, this fails due to EADDRNOTAVAIL; the kernel does not support
IPv4 multicast addresses through PF_INET6 socket. In any case, Java
doing this is not very portable -- there is huge variance on how
various implementations treat the mapped addresses; Linux kernel
implementations are not going to change  and as a result,
applications using MulticastSocket when an ipv4 group is specified on
IPv6 systems is failing.
The problems here were already identified 7+ years ago (e.g. an IETF
If you don't specify the group, this results in a PF_INET6 socket with
wildcard bind ("::"), and works to a degree but this has other,
already known, problems when multiple receivers exist on the saem
What needs to, IMHO, happen is that at least when creating
MulticastSocket with a specified group, Java implementation should
check whether the address is IPv4 or IPv6, and create a PF_INET6 or
PF_INET socket, instead of always creating PF_INET6 socket if IPv6 is
Another thing that could be useful would be to modify socket creation
mechanisms so that you could specify whether you want an ipv4 or ipv6
socket if you know which one you need.
Pekka Savola "You each name yourselves king, yet the
Netcore Oy kingdom bleeds."
Systems. Networks. Security. -- George R.R. Martin: A Clash of Kings
More information about the net-dev