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
-----------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4105138 Socket.getLocalAddress() returns incorrect byte order
- Closed