diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-06-17 19:11:56 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-06-17 19:11:56 +0000 |
commit | 2231720cfb16e664086b9c7e56e03cd8729c5c50 (patch) | |
tree | 53d149bf6edc47478ce21e8fc9959d026a950946 /libjava/java/net/InetSocketAddress.java | |
parent | 9228fac157aeefc6c2212565842b92c01c700ae9 (diff) | |
download | gcc-2231720cfb16e664086b9c7e56e03cd8729c5c50.tar.gz |
2003-06-17 Michael Koch <konqueror@gmx.de>
* java/net/InetSocketAddress.java
(InetSocketAddress): Use wildcard address if addr is null.
(InetSocketAddress): Dont duplicate implementation.
(InetSocketAddress): Throw exception when hostname is null.
* java/net/Socket.java:
Reworked imports.
(Socket): Throw exception when raddr is null, handle case when laddr
is null.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68106 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/net/InetSocketAddress.java')
-rw-r--r-- | libjava/java/net/InetSocketAddress.java | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/libjava/java/net/InetSocketAddress.java b/libjava/java/net/InetSocketAddress.java index 3c54b51a0f0..c720fbcfe61 100644 --- a/libjava/java/net/InetSocketAddress.java +++ b/libjava/java/net/InetSocketAddress.java @@ -69,6 +69,9 @@ public class InetSocketAddress extends SocketAddress { if (port < 0 || port > 65535) throw new IllegalArgumentException(); + + if (addr == null) + addr = InetAddress.ANY_IF; this.addr = addr; this.port = port; @@ -85,25 +88,9 @@ public class InetSocketAddress extends SocketAddress public InetSocketAddress(int port) throws IllegalArgumentException { - if (port < 0 || port > 65535) - throw new IllegalArgumentException(); - - this.port = port; - - try - { - byte[] any = { 0, 0, 0, 0 }; - this.addr = InetAddress.getByAddress (any); - this.hostname = "0.0.0.0"; - } - catch (UnknownHostException e) - { - this.addr = null; - this.hostname = ""; - } + this ((InetAddress) null, port); } - /** * Constructs an InetSocketAddress instance. * @@ -115,7 +102,8 @@ public class InetSocketAddress extends SocketAddress public InetSocketAddress(String hostname, int port) throws IllegalArgumentException { - if (port < 0 || port > 65535) + if (port < 0 || port > 65535 + || hostname == null) throw new IllegalArgumentException(); this.port = port; |