2003-11-26 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java (DategramSocket, bind): Moved binding code from DatagramSocket constructor to bind method. From-SVN: r73952
This commit is contained in:
parent
4aa74bd346
commit
dddfde5fc3
|
@ -1,3 +1,9 @@
|
||||||
|
2003-11-26 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
|
* java/net/DatagramSocket.java
|
||||||
|
(DategramSocket, bind): Moved binding code from DatagramSocket
|
||||||
|
constructor to bind method.
|
||||||
|
|
||||||
2003-11-26 Michael Koch <konqueror@gmx.de>
|
2003-11-26 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
* java/net/DatagramSocket.java
|
* java/net/DatagramSocket.java
|
||||||
|
|
|
@ -187,44 +187,8 @@ public class DatagramSocket
|
||||||
impl = new PlainDatagramSocketImpl();
|
impl = new PlainDatagramSocketImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address == null)
|
if (address != null)
|
||||||
return;
|
bind(address);
|
||||||
|
|
||||||
if (! (address instanceof InetSocketAddress))
|
|
||||||
throw new SocketException("unsupported address type");
|
|
||||||
|
|
||||||
InetAddress addr = ((InetSocketAddress) address).getAddress();
|
|
||||||
int port = ((InetSocketAddress) address).getPort();
|
|
||||||
|
|
||||||
if (port < 0 || port > 65535)
|
|
||||||
throw new IllegalArgumentException("Invalid port: " + port);
|
|
||||||
|
|
||||||
SecurityManager s = System.getSecurityManager();
|
|
||||||
if (s != null)
|
|
||||||
s.checkListen(port);
|
|
||||||
|
|
||||||
if (addr == null)
|
|
||||||
addr = InetAddress.ANY_IF;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getImpl().bind(port, addr);
|
|
||||||
}
|
|
||||||
catch (SocketException exception)
|
|
||||||
{
|
|
||||||
getImpl().close();
|
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
catch (RuntimeException exception)
|
|
||||||
{
|
|
||||||
getImpl().close();
|
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
catch (Error error)
|
|
||||||
{
|
|
||||||
getImpl().close();
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This needs to be accessible from java.net.MulticastSocket
|
// This needs to be accessible from java.net.MulticastSocket
|
||||||
|
@ -671,15 +635,40 @@ public class DatagramSocket
|
||||||
if (! (address instanceof InetSocketAddress))
|
if (! (address instanceof InetSocketAddress))
|
||||||
throw new IllegalArgumentException("unsupported address type");
|
throw new IllegalArgumentException("unsupported address type");
|
||||||
|
|
||||||
InetSocketAddress tmp = (InetSocketAddress) address;
|
InetAddress addr = ((InetSocketAddress) address).getAddress();
|
||||||
|
int port = ((InetSocketAddress) address).getPort();
|
||||||
|
|
||||||
|
if (port < 0 || port > 65535)
|
||||||
|
throw new IllegalArgumentException("Invalid port: " + port);
|
||||||
|
|
||||||
SecurityManager s = System.getSecurityManager ();
|
SecurityManager s = System.getSecurityManager ();
|
||||||
if (s != null)
|
if (s != null)
|
||||||
s.checkListen(tmp.getPort ());
|
s.checkListen(port);
|
||||||
|
|
||||||
getImpl().bind (tmp.getPort (), tmp.getAddress ());
|
if (addr == null)
|
||||||
|
addr = InetAddress.ANY_IF;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
getImpl().bind(port, addr);
|
||||||
bound = true;
|
bound = true;
|
||||||
}
|
}
|
||||||
|
catch (SocketException exception)
|
||||||
|
{
|
||||||
|
getImpl().close();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
catch (RuntimeException exception)
|
||||||
|
{
|
||||||
|
getImpl().close();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
catch (Error error)
|
||||||
|
{
|
||||||
|
getImpl().close();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the datagram socket is closed.
|
* Checks if the datagram socket is closed.
|
||||||
|
|
Loading…
Reference in New Issue