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. From-SVN: r68106
This commit is contained in:
committed by
Michael Koch
parent
6f3aed57fb
commit
7d8f4ff955
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user