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

Socket.getLocalAddress() returns 0.0.0.0 on outbound TCP for IPv6 sockets

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      Tried all available 1.5 versions +
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
      Have not tried 1.7.

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Dual IP stack (IPv4 and IPv6)

      A DESCRIPTION OF THE PROBLEM :
      This bug must be related to bug JDK-6210227, which has not been fixed despite the claimed "fixed" status.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Configure IPv6 an a Windows box.

      2. The problem can be easily reproduced with the attached code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Originator's IP address of the outbound TCP connection.
      ACTUAL -
      0.0.0.0

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error. The call just works incorrectly

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import java.util.*;
      import java.net.*;

      public class Interfaceid {
       
      /**
      * In order to reproduce the bug the system that runs this class must support
      * IPv6.
      */
      public static void main(String[] args) {
                  if( null == args[0] ) {
                              System.out.println("usage: java Interfaceid <IPv6address>");
                  } else {
                              String sHostname = args[0];
                  System.out.println("get ip and hostname of our interface to "+sHostname);
                  try {
                              InetAddress ina = InetAddress.getByName( sHostname );
                              InetSocketAddress isa = new InetSocketAddress( ina, 80 );
                      Socket s = new Socket();
                      s.connect( isa, 1000 );
                      InetAddress iaLocal = s.getLocalAddress(); // if this comes back as 0.0.0.0 this would demonstrate issue
                      String sLocalHostname = iaLocal.getHostName();
                      System.out.println("local ip is "+iaLocal.getHostAddress() );
                      System.out.println("local hostname is "+sLocalHostname );
                  } catch(Exception e) {
                              System.out.println("Exception happened");
                  }
              }
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Unknown. Because of this problem it is impossible to implement RFC 2428 in Java.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ryeung Roger Yeung (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: