diff options
author | Michael Koch <konqueror@gmx.de> | 2002-10-03 11:23:33 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2002-10-03 11:23:33 +0000 |
commit | e832ab3c91f01cdb1bd618ffe4a8e00505264d22 (patch) | |
tree | aff5f3ab2e4d52928ed330a39300502da4fdce8b /libjava/java/net/Socket.java | |
parent | 3eacc81d00aa85d20a95069177f608edb4f8104c (diff) | |
download | gcc-e832ab3c91f01cdb1bd618ffe4a8e00505264d22.zip gcc-e832ab3c91f01cdb1bd618ffe4a8e00505264d22.tar.gz gcc-e832ab3c91f01cdb1bd618ffe4a8e00505264d22.tar.bz2 |
2002-09-30 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java
(receive): Check with SecurityManager AFTER the packet is received,
check if connected to multicast address, documentation added.
(send): Only check SecurityManager if connected, check address of
packet to send.
(connect): Implemented, documentation added.
* java/net/Inet6Address.java: New file (not added yet to Makefile.am).
* java/net/InetSocketAddress.java
(whole file): Reindented.
(hostname): New attribute.
(InetSocketAddress): Initialize new attribute.
(getAddress): Documentation added.
(getHostName): Documentation added.
(getPort): Documentation added.
(hashCode): Documentation added.
(isUnresolved): Documentation added.
(toString): Conform to output of JDK 1.4.1, documentation added.
* java/net/MulticastSocket.java
(joinGroup): Removed FIXME, documentation added.
(leaveGroup): Removed FIXME, documentation added.
(send): Documentation added.
* java/net/Socket.java
(inputShutdown): New variable.
(outputShutdown): New variable.
(Socket): Initialize new variables.
(getRemoteSocketAddress): Check if connected.
(shutdownInput): Set new variable.
(shutdownOutput): Set new variable.
(isConnected): New method.
(isClosed): New method.
(isInputShutdown): New method.
(isOutputShutdown): New method.
* java/net/URLStreamHandler.java
(URLStreamHandler): New method.
(openConnection): Added documentation.
(parseURL): Added documentation.
(getHostAddress): New method.
(getDefaultPort): New method.
From-SVN: r57772
Diffstat (limited to 'libjava/java/net/Socket.java')
-rw-r--r-- | libjava/java/net/Socket.java | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/libjava/java/net/Socket.java b/libjava/java/net/Socket.java index 82265dd..b900801 100644 --- a/libjava/java/net/Socket.java +++ b/libjava/java/net/Socket.java @@ -80,6 +80,9 @@ public class Socket */ SocketImpl impl; + private boolean inputShutdown; + private boolean outputShutdown; + SocketChannel ch; // this field must have been set if created by SocketChannel // Constructors @@ -97,6 +100,9 @@ public class Socket impl = factory.createSocketImpl(); else impl = new PlainSocketImpl(); + + inputShutdown = false; + outputShutdown = false; } /** @@ -118,6 +124,8 @@ public class Socket protected Socket (SocketImpl impl) throws SocketException { this.impl = impl; + this.inputShutdown = false; + this.outputShutdown = false; } /** @@ -264,6 +272,9 @@ public class Socket boolean stream) throws IOException { this(); + this.inputShutdown = false; + this.outputShutdown = false; + if (impl == null) throw new IOException("Cannot initialize Socket implementation"); @@ -457,6 +468,9 @@ public class Socket */ public SocketAddress getRemoteSocketAddress() { + if (!isConnected ()) + return null; + return new InetSocketAddress (impl.getInetAddress (), impl.getPort ()); } @@ -886,10 +900,12 @@ public class Socket * * @exception IOException If an error occurs. */ - public void shutdownInput() throws IOException + public void shutdownInput() throws IOException { if (impl != null) impl.shutdownInput(); + + inputShutdown = true; } /** @@ -901,6 +917,8 @@ public class Socket { if (impl != null) impl.shutdownOutput(); + + outputShutdown = true; } /** @@ -994,10 +1012,43 @@ public class Socket } /** + * Checks if the socket is connected + */ + public boolean isConnected () + { + return impl.getInetAddress () != null; + } + + /** * Checks if the socket is already bound. */ public boolean isBound () { return getLocalAddress () != null; } + + /** + * Checks if the socket is closed. + */ + public boolean isClosed () + { + // FIXME: implement this. + return false; + } + + /** + * Checks if the socket's input stream is shutdown + */ + public boolean isInputShutdown () + { + return inputShutdown; + } + + /** + * Checks if the socket's output stream is shutdown + */ + public boolean isOutputShutdown () + { + return outputShutdown; + } } |