United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6230761 (so) NIO channels with IPv6 on Windows
JDK-6230761 : (so) NIO channels with IPv6 on Windows

Details
Type:
Enhancement
Submit Date:
2005-02-18
Status:
Resolved
Updated Date:
2012-10-10
Project Name:
JDK
Resolved Date:
2012-07-30
Component:
core-libs
OS:
windows_xp,windows
Sub-Component:
java.nio
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0,6
Fixed Versions:
6u34 (b31)

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:
Relates:

Sub Tasks

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

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
                                     
2005-02-18
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.
                                     
2005-10-28
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.
                                     
2006-09-22
EVALUATION

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

sync from 6u33-b34
                                     
2012-07-20



Hardware and Software, Engineered to Work Together