[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commit-cp] java.net.Socket#getLocalAddress() should return anylocal if
From: |
Ito Kazumitsu |
Subject: |
[commit-cp] java.net.Socket#getLocalAddress() should return anylocal if not bound |
Date: |
Wed, 15 Sep 2004 01:15:50 +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
I suggest java.net.Socket should be fixed.
2004-09-14 Ito Kazumitsu <address@hidden>
* java/net/Socket.java(getLocalAddress()):
If the socket is not bound yet,
return InetAddress.ANY_IF rather than null.
--- java/net/Socket.java.orig Mon Jul 26 21:13:57 2004
+++ java/net/Socket.java Tue Sep 14 14:15:51 2004
@@ -479,7 +479,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 isAnyLocalAddress()
+ * is true, is returned.
*
* @return The local address
*
@@ -487,21 +488,25 @@
*/
public InetAddress getLocalAddress()
{
- if (! isBound())
- return null;
-
InetAddress addr = null;
- try
+ if (! isBound())
{
- addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
+ addr = InetAddress.ANY_IF;
}
- catch (SocketException e)
+ else
{
- // (hopefully) shouldn't happen
- // throw new java.lang.InternalError
- // ("Error in PlainSocketImpl.getOption");
- return null;
+ try
+ {
+ addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
+ }
+ catch (SocketException e)
+ {
+ // (hopefully) shouldn't happen
+ // throw new java.lang.InternalError
+ // ("Error in PlainSocketImpl.getOption");
+ return null;
+ }
}
// FIXME: According to libgcj, checkConnect() is supposed to be called
- [commit-cp] java.net.Socket#getLocalAddress() should return anylocal if not bound,
Ito Kazumitsu <=