diff options
| author | Jeroen Frijters <jeroen@sumatra.nl> | 2006-09-19 05:47:38 +0000 |
|---|---|---|
| committer | Jeroen Frijters <jeroen@sumatra.nl> | 2006-09-19 05:47:38 +0000 |
| commit | de22da61863ed89fa877fb423904f31ab26730fc (patch) | |
| tree | 200e84bc0d9e1c04bef65639845b02b4ac7295ec /java | |
| parent | 567c1a7d95d014b5429868b96e4a714999dd6ed3 (diff) | |
| download | classpath-de22da61863ed89fa877fb423904f31ab26730fc.tar.gz | |
2006-09-19 Jeroen Frijters <jeroen@frijters.net>
* java/net/ServerSocket.java
(port): New field.
(bind): Set port field.
(close): Set impl to null.
(isClosed): Check impl and channel instead of using VMChannel.
(toString): Use port field and getLocalPort() method.
* java/net/Socket.java
(isClosed): Check impl and channel instead of using VMChannel.
Diffstat (limited to 'java')
| -rw-r--r-- | java/net/ServerSocket.java | 22 | ||||
| -rw-r--r-- | java/net/Socket.java | 14 |
2 files changed, 13 insertions, 23 deletions
diff --git a/java/net/ServerSocket.java b/java/net/ServerSocket.java index b689cf1d1..116227f8f 100644 --- a/java/net/ServerSocket.java +++ b/java/net/ServerSocket.java @@ -39,7 +39,6 @@ exception statement from your version. */ package java.net; import gnu.java.net.PlainSocketImpl; -import gnu.java.nio.VMChannel; import java.io.IOException; import java.nio.channels.IllegalBlockingModeException; @@ -80,6 +79,7 @@ public class ServerSocket * We need to retain the local address even after the socket is closed. */ private InetSocketAddress local; + private int port; /* * This constructor is only used by java.nio. @@ -238,7 +238,8 @@ public class ServerSocket try { - impl.bind(addr, tmp.getPort()); + port = tmp.getPort(); + impl.bind(addr, port); impl.listen(backlog); local = new InetSocketAddress( (InetAddress) impl.getOption(SocketOptions.SO_BINDADDR), @@ -379,10 +380,11 @@ public class ServerSocket */ public void close() throws IOException { - if (isClosed()) - return; - - impl.close(); + if (impl != null) + { + impl.close(); + impl = null; + } } /** @@ -422,10 +424,8 @@ public class ServerSocket */ public boolean isClosed() { - VMChannel vmchannel = ((PlainSocketImpl) impl).getVMChannel(); - if (vmchannel == null) // Not created yet. - return false; - return vmchannel.getState().isClosed(); + ServerSocketChannel channel = getChannel(); + return impl == null || (channel != null && ! channel.isOpen()); } /** @@ -573,7 +573,7 @@ public class ServerSocket return "ServerSocket[unbound]"; return ("ServerSocket[addr=" + getInetAddress() + ",port=" - + impl.getPort() + ",localport=" + impl.getLocalPort() + "]"); + + port + ",localport=" + getLocalPort() + "]"); } /** diff --git a/java/net/Socket.java b/java/net/Socket.java index 76140e526..63ba43727 100644 --- a/java/net/Socket.java +++ b/java/net/Socket.java @@ -39,7 +39,6 @@ exception statement from your version. */ package java.net; import gnu.java.net.PlainSocketImpl; -import gnu.java.nio.VMChannel; import java.io.IOException; import java.io.InputStream; @@ -1223,17 +1222,8 @@ public class Socket */ public boolean isClosed() { - if (impl == null) - return true; - if (impl instanceof PlainSocketImpl) - { - VMChannel vmchannel = ((PlainSocketImpl) impl).getVMChannel(); - if (vmchannel == null) - return false; // Not created yet. - VMChannel.State state = vmchannel.getState(); - return state.isClosed(); - } - return false; + SocketChannel channel = getChannel(); + return impl == null || (channel != null && ! channel.isOpen()); } /** |
