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

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

    XMLWordPrintable

Details

    • 1.2beta4
    • x86
    • generic, solaris_2.6
    • 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

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: