diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-17 11:17:28 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-17 11:17:28 +0000 |
commit | 77588d56b0618ace29d51ffc29e543b72e5c592b (patch) | |
tree | e934e1ac095dfb7259f339c2194657fa45f964a2 /libjava | |
parent | 1337c7b6d210d29be76628454be8c234ab9acb27 (diff) | |
download | gcc-77588d56b0618ace29d51ffc29e543b72e5c592b.tar.gz |
2004-07-17 Jeroen Frijters <jeroen@frijters.net>
* java/net/DatagramPacket.java (setAddress): Removed check for
null address.
2004-07-17 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java
(getLocalAddress): Check if socket is bound or not.
* java/net/Socket.java
(getLocalAddrss): Check if socket is bound or not.
(getPort): Return -1 when not connected. Dont check getImpl() for
null.
(setReuseAddress): Check if socket is closed.
(isConnected): Check if getImpl() returns null.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84864 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 16 | ||||
-rw-r--r-- | libjava/java/net/DatagramPacket.java | 3 | ||||
-rw-r--r-- | libjava/java/net/DatagramSocket.java | 5 | ||||
-rw-r--r-- | libjava/java/net/Socket.java | 14 |
4 files changed, 30 insertions, 8 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index cbb023adcc6..b73fa460978 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,19 @@ +2004-07-17 Jeroen Frijters <jeroen@frijters.net> + + * java/net/DatagramPacket.java (setAddress): Removed check for + null address. + +2004-07-17 Michael Koch <konqueror@gmx.de> + + * java/net/DatagramSocket.java + (getLocalAddress): Check if socket is bound or not. + * java/net/Socket.java + (getLocalAddrss): Check if socket is bound or not. + (getPort): Return -1 when not connected. Dont check getImpl() for + null. + (setReuseAddress): Check if socket is closed. + (isConnected): Check if getImpl() returns null. + 2004-07-17 Mark Wielaard <mark@klomp.org> * java/awt/event/InvocationEvent.java (dispatch): Synchronize diff --git a/libjava/java/net/DatagramPacket.java b/libjava/java/net/DatagramPacket.java index 8ff64435c2b..549a3609a3d 100644 --- a/libjava/java/net/DatagramPacket.java +++ b/libjava/java/net/DatagramPacket.java @@ -278,9 +278,6 @@ public final class DatagramPacket */ public synchronized void setAddress(InetAddress address) { - if (address == null) - throw new NullPointerException("Null address"); - this.address = address; } diff --git a/libjava/java/net/DatagramSocket.java b/libjava/java/net/DatagramSocket.java index 2808d82428b..d29d1223498 100644 --- a/libjava/java/net/DatagramSocket.java +++ b/libjava/java/net/DatagramSocket.java @@ -1,5 +1,6 @@ /* DatagramSocket.java -- A class to model UDP sockets - Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -282,7 +283,7 @@ public class DatagramSocket */ public InetAddress getLocalAddress() { - if (isClosed()) + if (! isBound()) return null; InetAddress localAddr; diff --git a/libjava/java/net/Socket.java b/libjava/java/net/Socket.java index 43c6f3c3d50..714a958e6aa 100644 --- a/libjava/java/net/Socket.java +++ b/libjava/java/net/Socket.java @@ -488,6 +488,9 @@ public class Socket */ public InetAddress getLocalAddress() { + if (! isBound()) + return null; + InetAddress addr = null; try @@ -523,12 +526,11 @@ public class Socket public int getPort() { if (! isConnected()) - return 0; + return -1; try { - if (getImpl() != null) - return getImpl().getPort(); + return getImpl().getPort(); } catch (SocketException e) { @@ -1155,6 +1157,9 @@ public class Socket */ public void setReuseAddress(boolean reuseAddress) throws SocketException { + if (isClosed()) + throw new SocketException("socket is closed"); + getImpl().setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(reuseAddress)); } @@ -1217,6 +1222,9 @@ public class Socket { try { + if (getImpl() == null) + return false; + return getImpl().getInetAddress() != null; } catch (SocketException e) |