[multiple changes]
2004-07-17 Jeroen Frijters <jeroen@frijters.net> * java/net/DatagramPacket.java (setAddress): Removed check for null address. 2004-07-17 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java (getLocalAddress): Check if socket is bound or not. * java/net/Socket.java (getLocalAddrss): Check if socket is bound or not. (getPort): Return -1 when not connected. Dont check getImpl() for null. (setReuseAddress): Check if socket is closed. (isConnected): Check if getImpl() returns null. From-SVN: r84864
This commit is contained in:
parent
4928181ca2
commit
320e32f649
4 changed files with 30 additions and 8 deletions
|
@ -488,6 +488,9 @@ public class Socket
|
|||
*/
|
||||
public InetAddress getLocalAddress()
|
||||
{
|
||||
if (! isBound())
|
||||
return null;
|
||||
|
||||
InetAddress addr = null;
|
||||
|
||||
try
|
||||
|
@ -523,12 +526,11 @@ public class Socket
|
|||
public int getPort()
|
||||
{
|
||||
if (! isConnected())
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
if (getImpl() != null)
|
||||
return getImpl().getPort();
|
||||
return getImpl().getPort();
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
|
@ -1155,6 +1157,9 @@ public class Socket
|
|||
*/
|
||||
public void setReuseAddress(boolean reuseAddress) throws SocketException
|
||||
{
|
||||
if (isClosed())
|
||||
throw new SocketException("socket is closed");
|
||||
|
||||
getImpl().setOption(SocketOptions.SO_REUSEADDR,
|
||||
Boolean.valueOf(reuseAddress));
|
||||
}
|
||||
|
@ -1217,6 +1222,9 @@ public class Socket
|
|||
{
|
||||
try
|
||||
{
|
||||
if (getImpl() == null)
|
||||
return false;
|
||||
|
||||
return getImpl().getInetAddress() != null;
|
||||
}
|
||||
catch (SocketException e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue