From 927818a5984c6fe521cd8e6c9a11c7f3599a87a5 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Sat, 11 Jan 2003 01:17:19 +0000 Subject: 2003-01-10 Michael Koch * java/net/DatagramSocket.java (ch): Description added. (remotePort): Initialize with -1. (connect): Doesnt throws SocketException. * java/net/MulticastSocket.java (setInterface): Merge with Classpath. * java/net/ServerSocket.java (closed): New member variable. (bind): Check if socket is closed. (close): Close an associated channel too, set new value to closed. (isBound): Reindented. (isClosed): Implemented. * java/net/Socket.java (closed): New member variable. (bind): Check if socket is closed. (connect): Check if socket is closed. (close): Close an associated channel too, set new value to closed. (isClosed): Implemented. From-SVN: r61185 --- libjava/java/net/ServerSocket.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'libjava/java/net/ServerSocket.java') diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java index 62917b6..e2f8e63 100644 --- a/libjava/java/net/ServerSocket.java +++ b/libjava/java/net/ServerSocket.java @@ -77,6 +77,8 @@ public class ServerSocket */ private ServerSocketChannel ch; + private boolean closed = false; + /** * Constructor that simply sets the implementation. * @@ -200,6 +202,9 @@ public class ServerSocket */ public void bind (SocketAddress endpoint, int backlog) throws IOException { + if (closed) + throw new SocketException ("ServerSocket is closed"); + if (impl == null) throw new IOException ("Cannot initialize Socket implementation"); @@ -315,7 +320,13 @@ public class ServerSocket */ public void close () throws IOException { - impl.close(); + if (impl != null) + impl.close (); + + if (ch != null) + ch.close (); + + closed = true; } /** @@ -358,8 +369,7 @@ public class ServerSocket */ public boolean isClosed() { - // FIXME: implement this - return false; + return closed; } /** -- cgit v1.1