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

java.net.Socket.getLocalAddress() works wrong on Solaris x86

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta4
    • CPU:
      x86
    • OS:
      generic, solaris_2.6
    • Verification:
      Verified

      Description



      Name: yyC67448 Date: 01/25/98



      The java.net.Socket.getLocalAddress() returns address in incorrect byte-order on
      Solaris 2.6 x86.

      As soon as i386 architecture is little-endian returned address should
      be translated from network-order to host-order....

      Here is the test demonstrating the bug:

      -------------------------------- Test.java -----------------------------
      import java.io.*;
      import java.net.*;

      class test
      {

        public static void main(String args[])
        {
          Socket soc = null;
          InetAddress sin = null;
          int port = 21; // Use telnet service port number.... hope it's enabled..
       
          try {
           sin = InetAddress.getLocalHost();
           soc = new Socket(sin, port, sin, 0);
          } catch(Exception e)
          {
              System.out.println("Exception :" + e);
              System.exit(-1);
          }
         
          if(sin.equals(soc.getLocalAddress()))
          {
             System.out.println("Passed. OKAY");
             try {
               soc.close();
             } catch(Exception e) {}
             System.exit(0);
          }

          System.out.println("Failed. LocalAddress = " + soc.getLocalAddress());
         
          try {
           soc.close();
          } catch(Exception e) {}
          System.exit(-1);

        }
      }


      ---------------------- Output from the test on Solaris x86 -----
      Failed. LocalAddress = 196.205.168.192/196.205.168.192
      -----------------------------------------------------------------
      ---------------------- Output from the test on Solaris SPARC ---
      Passed. OKAY
      -----------------------------------------------------------------

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mmcclosksunw Michael Mccloskey (Inactive)
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: