java.net.Socket.getLocalPort() problem

Archie Cobbs kaffe@rufus.w3.org
Fri, 5 May 2000 16:53:26 -0700 (PDT)


Nic Ferrier writes:
> I think I've found a problem with java.net.Socket.getLocalPort()
> 
> A socket created from:
>    SocketServer.accept() 
> 
> reports it's local port as 0.

Try this patch and let me know if that fixes it.

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com

Index: ServerSocket.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/net/ServerSocket.java,v
retrieving revision 1.8
diff -u -r1.8 ServerSocket.java
--- ServerSocket.java	1999/07/20 06:00:20	1.8
+++ ServerSocket.java	2000/05/05 23:53:10
@@ -56,6 +56,7 @@
 
 public Socket accept() throws IOException {
 	Socket s = new Socket();
+	s.impl.localport = impl.localport;
 	implAccept(s);
 	return (s);
 }