diff options
author | Michael Koch <konqueror@gmx.de> | 2003-06-18 09:44:40 +0000 |
---|---|---|
committer | Michael Koch <konqueror@gmx.de> | 2003-06-18 09:44:40 +0000 |
commit | 6c409b7b81c880372be52766ac4243757f669695 (patch) | |
tree | fe5f0b65877c21216d5de79860a9358c94992ab7 /java/net/Socket.java | |
parent | e1ad825e4817d5e489eb8f63e4b3cfcbad72af65 (diff) | |
download | classpath-6c409b7b81c880372be52766ac4243757f669695.tar.gz |
2003-06-18 Michael Koch <konqueror@gmx.de>
* java/net/InetSocketAddress.java,
java/net/Socket.java:
New versions from libgcj.
Diffstat (limited to 'java/net/Socket.java')
-rw-r--r-- | java/net/Socket.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/java/net/Socket.java b/java/net/Socket.java index 8535fa9ef..38b31ec8c 100644 --- a/java/net/Socket.java +++ b/java/net/Socket.java @@ -37,7 +37,9 @@ exception statement from your version. */ package java.net; -import java.io.*; +import java.io.InputStream; +import java.io.IOException; +import java.io.OutputStream; import java.nio.channels.SocketChannel; import java.nio.channels.IllegalBlockingModeException; @@ -87,8 +89,6 @@ public class Socket private boolean closed = false; - // Constructors - /** * Initializes a new instance of <code>Socket</code> object without * connecting to a remote host. This useful for subclasses of socket that @@ -282,6 +282,9 @@ public class Socket { this(); + if (raddr == null) + throw new NullPointerException (); + if (impl == null) throw new IOException("Cannot initialize Socket implementation"); @@ -289,8 +292,12 @@ public class Socket if (sm != null) sm.checkConnect(raddr.getHostName(), rport); - // bind/connect socket - bind (new InetSocketAddress (laddr, lport)); + // bind socket + SocketAddress bindaddr = + laddr == null ? null : new InetSocketAddress (laddr, lport); + bind (bindaddr); + + // connect socket connect (new InetSocketAddress (raddr, rport)); // FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port, |