Index: java/net/DatagramSocket.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/DatagramSocket.java,v retrieving revision 1.40 diff -u -b -B -r1.40 DatagramSocket.java --- java/net/DatagramSocket.java 8 Apr 2004 16:26:03 -0000 1.40 +++ java/net/DatagramSocket.java 17 Jul 2004 07:33:37 -0000 @@ -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 InetAddress getLocalAddress() { - if (isClosed()) + if (! isBound()) return null; InetAddress localAddr; Index: java/net/Socket.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/Socket.java,v retrieving revision 1.44 diff -u -b -B -r1.44 Socket.java --- java/net/Socket.java 21 Apr 2004 10:41:23 -0000 1.44 +++ java/net/Socket.java 17 Jul 2004 07:33:37 -0000 @@ -488,6 +488,9 @@ */ public InetAddress getLocalAddress() { + if (! isBound()) + return null; + InetAddress addr = null; try @@ -523,11 +526,10 @@ public int getPort() { if (! isConnected()) - return 0; + return -1; try { - if (getImpl() != null) return getImpl().getPort(); } catch (SocketException e) @@ -1155,6 +1157,9 @@ */ 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 @@ { try { + if (getImpl() == null) + return false; + return getImpl().getInetAddress() != null; } catch (SocketException e)