java.net.BindException is thrown when a MulticastSocket is constructed with MulticastSocket(InetSocketAddress address) if the address is derived from an IPv6 address.
See the following program and output:
import java.net.*;
public class Test2 {
public static void main(String[] argv) throws Exception {
InetAddress localHost = InetAddress.getByName(argv[0]);
InetSocketAddress addr = new InetSocketAddress(localHost, 0);
MulticastSocket ms = new MulticastSocket(addr);
}
}
/usr/java/jdk1.5.0/bin/java Test2 fe80:0:0:0:207:e9ff:fe62:7e18
Exception in thread "main" java.net.BindException: Cannot assign requested address
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82)
at java.net.DatagramSocket.bind(DatagramSocket.java:368)
at java.net.MulticastSocket.<init>(MulticastSocket.java:147)
at Test2.main(Test2.java:7)
uname -a
Linux d-usca22-163-163 2.6.4-52-smp #1 SMP Wed Apr 7 02:11:20 UTC 2004 i686 i686 i386 GNU/Linux
ifconfig
eth0 Link encap:Ethernet HWaddr 00:07:E9:62:7E:18
inet addr:129.145.163.163 Bcast:129.145.163.255 Mask:255.255.254.0
inet6 addr: fe80::207:e9ff:fe62:7e18/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:532432 errors:0 dropped:0 overruns:0 frame:0
TX packets:361266 errors:0 dropped:0 overruns:0 carrier:0
collisions:94403 txqueuelen:1000
RX bytes:240731598 (229.5 Mb) TX bytes:35615686 (33.9 Mb)
Base address:0xcc00 Memory:ff8e0000-ff900000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:65139 errors:0 dropped:0 overruns:0 frame:0
TX packets:65139 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:28721436 (27.3 Mb) TX bytes:28721436 (27.3 Mb)
This problem is reproducible on SuSE Linux, but not on Solaris.