JDK-6230761 : (so) NIO channels with IPv6 on Windows
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows,windows_xp
  • CPU: x86
  • Submitted: 2005-02-18
  • Updated: 2017-05-16
  • Resolved: 2012-07-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6u33Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_01"
Java (TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP
Professional
Version 2002
Service Pack 2

A DESCRIPTION OF THE PROBLEM :
Using IPv6 addresses in conjuction with NIO channels raises a "java.net.SocketException: Address family not supported by protocol
family".

Doing the same operation directly on a socket instance (i.e. without getting the socket from a channel) works.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply execute the piece of code below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The program should run without exception (as it is the case for linux/solaris boxes on which it has been tested too).

Should display:
==> 1
==> 2
==> 3

ACTUAL -
==> 1
==> 2
java.net.SocketException: Address family not supported by protocol
family: bind
        at sun.nio.ch.Net.bind(Native Method)
        at
sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelI��mpl.java:119)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java��:59)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java��:52)
        at external.ipv6.main(ipv6.java:31)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Stacktrace is displayed by the application already.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.nio.channels.ServerSocketChannel;


class ipv6 {
    static public void main(String[] notUsed) {
        try {
            byte[] addr = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1};

            InetAddress inetAddr = InetAddress.getByAddress(addr);

            InetSocketAddress addr_8501 = new
InetSocketAddress(inetAddr, 8501);
            InetSocketAddress addr_8502 = new
InetSocketAddress(inetAddr, 8502);

            System.out.println("==> 1");

            ServerSocket serverSocket = new ServerSocket();
            serverSocket.bind(addr_8501); // This works

            System.out.println("==> 2");

            ServerSocketChannel channel = ServerSocketChannel.open();
            channel.socket().bind(addr_8502); //This does not work

            System.out.println("==> 3");
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
} 

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Unknown.
###@###.### 2005-2-18 06:41:28 GMT

Comments
EVALUATION sync from 6u33-b34
20-07-2012

EVALUATION This has been integrated into jdk7 build 36 via 4640544.
23-08-2008

EVALUATION -- 9/22/06: The IPv6 support in Windows XP is based on the Microsoft Research IPv6 implementation. It is separate to the IPv4 stack and does not support dual mode sockets. The classic networking implementation (java.net.Socket et. al.) was updated in J2SE 5.0 to use this IPv6 stack. It achieves this by creating two sockets (one IPv4 and one IPv6). That was a short term solution to provide some limited support for IPv6 on Windows. A new IPv6 stack arrives in Windows Vista. This stack is integrated and supports dual mode sockets. The plan is to update the NIO implementation in jdk7 to use dual mode sockets on Windows Vista when IPv6 is enabled.
22-09-2006

EVALUATION Supporting IPv6 on Windows XP will involve some messy implementation changes. It is too risky to attempt this now for mustang so I will re-commit this RFE to dolphin. This also gives time to evaluate the updated IPv6 stack in Windows Vista.
28-10-2005

EVALUATION We're working on IPv6 support in nio right now. We expect it to be part of the Mustang (jdk6.0) release. ###@###.### 2005-2-18 15:21:30 GMT
18-02-2005