[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] java/net/Socket.java and java/net/ServerSocket
From: |
Ito Kazumitsu |
Subject: |
[cp-patches] java/net/Socket.java and java/net/ServerSocket |
Date: |
Sat, 18 Sep 2004 07:50:21 +0900 |
User-agent: |
EMH/1.10.0 SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.2 (i386-unknown-freebsd4.7) MULE/5.0 (SAKAKI) |
Hi,
As reported in
http://www.kaffe.org/pipermail/kaffe/2004-September/099697.html
and
http://www.kaffe.org/pipermail/kaffe/2004-September/099714.html
there seems to be two bugs in java.net.Socket:
(1) When the socket is not bound, getLocalAddress() it is expected to
return an anylocal address, but it returns null.
(2) When the socket is created by ServerSocket#accept(), isBound()
is expected to return true and getLocalAddress() and getLocalPort()
is xpected to return the local addres and port the socket is bound to,
but isBound() returns fales, getLocalAddress() null, and getLocalPort()
-1.
Here is my proposed patch.
2004-09-18 Ito Kazumitsu <address@hidden>
* java/net/Socket.java
(getLocalAddress): If the socket is not bound yet,
return InetAddress.ANY_IF rather than null.
(bound): Made package-private.
* java/net/ServerSocket.java
(implAccept): Set the bound status and the local port.
bash-2.05b$ diff -u java/net/ServerSocket.java.orig java/net/ServerSocket.java
--- java/net/ServerSocket.java.orig Mon May 10 00:17:10 2004
+++ java/net/ServerSocket.java Sat Sep 18 07:15:27 2004
@@ -376,6 +376,8 @@
impl.accept(socket.impl);
socket.implCreated = true;
+ socket.bound = true;
+ socket.impl.localport = getLocalPort();
}
/**
bash-2.05b$ diff -u java/net/Socket.java.orig java/net/Socket.java
--- java/net/Socket.java.orig Wed Sep 1 06:49:31 2004
+++ java/net/Socket.java Fri Sep 17 07:31:13 2004
@@ -91,7 +91,8 @@
/**
* True if the socket is bound.
*/
- private boolean bound;
+ // package-private because ServerSocket.implAccept() needs to access it.
+ boolean bound;
/**
* True if input is shutdown.
@@ -479,7 +480,8 @@
/**
* Returns the local address to which this socket is bound. If this socket
- * is not connected, then <code>null</code> is returned.
+ * is not connected, then a wildcard address, for which
+ * @see isAnyLocalAddress() is <code>true</code>, is returned.
*
* @return The local address
*
@@ -488,7 +490,7 @@
public InetAddress getLocalAddress()
{
if (! isBound())
- return null;
+ return InetAddress.ANY_IF;
InetAddress addr = null;
bash-2.05b$
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] java/net/Socket.java and java/net/ServerSocket,
Ito Kazumitsu <=