I try to bind an IPv6 server socket in Java 1.6 on Windows 7, using this fragment:
ssock = ServerSocketChannel.open();
ServerSocket sock = ssock.socket();
sock.bind(new InetSocketAddress(InetAddress.getByAddress(new byte[16]), 0));
Unfortunately, this fails with an IOException: Address family not supported by protocol family: bind
I understand that Java is written with the assumption that Windows uses separate v4 and v6 stacks (even though Windows 7 doesn't), and that therefore binding a single socket for both v4 and v6 cannot work. However, this is not what I'm attempting to do: I merely want to bind a v6 socket to the any address (i.e. ::).
Edit: It also fails on Vista.
What am I doing wrong?