Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8000731

(so) NIO channels with IPv6 on Windows

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • Verification:
      Verified

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                robm Robert Mckenna
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: