[kaffe] libraries/javalib/java/net/Socket.java

Ito Kazumitsu ito.kazumitsu at mail.hidec.co.jp
Tue Sep 14 17:52:16 PDT 2004


In message "[kaffe] libraries/javalib/java/net/Socket.java"
    on 04/09/15, Gustavo Guillermo Perez <gustavo at compunauta.com> writes:

> I saw this, but I was thinking that uClibc, has a little bit of fault.
> I'm having problems with sockets at the moment of getting the port too, the 
> local one. May be something similar, I'm getting the -1 instead of 80. like 
> null addr instead of...
> I'll see trow this way, but may be uClibc now has something of fault.....

Yes,  attached below is a simple program which shows the possible bug
in kaffe.

When run with Sun's Java:

bash$ java TestSocket -s 9999 & sleep 5; java TestSocket -c localhost 9999
server: Socket[addr=/127.0.0.1,port=1173,localport=9999] isBound()=true getLocalAddress()=/127.0.0.1 getLocalPort()=9999client: Socket[addr=localhost/127.0.0.1,port=9999,localport=1173] isBound()=true getLocalAddress()=/127.0.0.1 getLocalPort()=1173

Whem run with kaffe:

bash$ kaffe TestSocket -s 9999 & sleep 5; kaffe TestSocket -c localhost 9999
server: Socket[addr=127.0.0.1/127.0.0.1,port=44306,localport=-1] isBound()=false
 getLocalAddress()=0.0.0.0/0.0.0.0 getLocalPort()=-1
client: Socket[addr=localhost/127.0.0.1,port=9999,localport=44306] isBound()=tru
e getLocalAddress()=127.0.0.1/127.0.0.1 getLocalPort()=44306

isBound() returns false when it should return true.

Test Program:

import java.net.*;

public final class TestSocket {

  public static final void main(String args[]) throws Exception {
    if (args[0].equals("-s")) {
      server(Integer.parseInt(args[1]));
    }
    else if (args[0].equals("-c")) {
      client(InetAddress.getByName(args[1]), Integer.parseInt(args[2]));
    }
  }

  private static void client(InetAddress host, int port) throws Exception {
    Socket s = new Socket(host, port);
    System.err.println("client: " + s +
      " isBound()=" + s.isBound() +
      " getLocalAddress()=" + s.getLocalAddress() +
      " getLocalPort()=" + s.getLocalPort());
  }

  private static void server(int port) throws Exception {
    ServerSocket server = null;
    server = new ServerSocket(port);
    Socket s = server.accept();
    System.err.println("server: " + s +
      " isBound()=" + s.isBound() +
      " getLocalAddress()=" + s.getLocalAddress() +
      " getLocalPort()=" + s.getLocalPort());
 }

}




More information about the kaffe mailing list