2003-03-02 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java (closed): New member variable. (close): Use closed variable. (getInetAddress): No need to call isConnected(). (getPort): No need to call isConnected(). (disconnect): Reset remoteAddress and remotePort, fixed typo. (isClosed): Reimplemented. From-SVN: r63662
This commit is contained in:
parent
c0daa90283
commit
37db829b93
2 changed files with 29 additions and 15 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2003-03-02 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
|
* java/net/DatagramSocket.java
|
||||||
|
(closed): New member variable.
|
||||||
|
(close): Use closed variable.
|
||||||
|
(getInetAddress): No need to call isConnected().
|
||||||
|
(getPort): No need to call isConnected().
|
||||||
|
(disconnect): Reset remoteAddress and remotePort, fixed typo.
|
||||||
|
(isClosed): Reimplemented.
|
||||||
|
|
||||||
2003-03-02 Michael Koch <konqueror@gmx.de>
|
2003-03-02 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
* configure.in: Added check for memory mapping of files.
|
* configure.in: Added check for memory mapping of files.
|
||||||
|
|
|
@ -88,6 +88,11 @@ public class DatagramSocket
|
||||||
*/
|
*/
|
||||||
private int remotePort = -1;
|
private int remotePort = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates when the socket is closed.
|
||||||
|
*/
|
||||||
|
private boolean closed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a DatagramSocket from a specified DatagramSocketImpl instance
|
* Creates a DatagramSocket from a specified DatagramSocketImpl instance
|
||||||
*
|
*
|
||||||
|
@ -201,9 +206,13 @@ public class DatagramSocket
|
||||||
*/
|
*/
|
||||||
public void close()
|
public void close()
|
||||||
{
|
{
|
||||||
impl.close();
|
if (!closed)
|
||||||
remoteAddress = null;
|
{
|
||||||
remotePort = -1;
|
impl.close();
|
||||||
|
remoteAddress = null;
|
||||||
|
remotePort = -1;
|
||||||
|
closed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,9 +226,6 @@ public class DatagramSocket
|
||||||
*/
|
*/
|
||||||
public InetAddress getInetAddress()
|
public InetAddress getInetAddress()
|
||||||
{
|
{
|
||||||
if (!isConnected ())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return remoteAddress;
|
return remoteAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,9 +240,6 @@ public class DatagramSocket
|
||||||
*/
|
*/
|
||||||
public int getPort()
|
public int getPort()
|
||||||
{
|
{
|
||||||
if (!isConnected ())
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return remotePort;
|
return remotePort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +268,7 @@ public class DatagramSocket
|
||||||
// s.checkConnect("localhost", -1);
|
// s.checkConnect("localhost", -1);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR);
|
return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR);
|
||||||
}
|
}
|
||||||
catch (SocketException ex)
|
catch (SocketException ex)
|
||||||
{
|
{
|
||||||
|
@ -273,12 +276,11 @@ public class DatagramSocket
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return InetAddress.getLocalHost();
|
return InetAddress.getLocalHost();
|
||||||
}
|
}
|
||||||
catch (UnknownHostException ex)
|
catch (UnknownHostException ex)
|
||||||
{
|
{
|
||||||
// FIXME: This should never happen, so how can we avoid this construct?
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +471,7 @@ public class DatagramSocket
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method disconnects this socket from the address/port it was
|
* This method disconnects this socket from the address/port it was
|
||||||
* conencted to. If the socket was not connected in the first place,
|
* connected to. If the socket was not connected in the first place,
|
||||||
* this method does nothing.
|
* this method does nothing.
|
||||||
*
|
*
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
|
@ -477,6 +479,8 @@ public class DatagramSocket
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
{
|
{
|
||||||
impl.disconnect();
|
impl.disconnect();
|
||||||
|
remoteAddress = null;
|
||||||
|
remotePort = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -596,7 +600,7 @@ public class DatagramSocket
|
||||||
*/
|
*/
|
||||||
public boolean isClosed()
|
public boolean isClosed()
|
||||||
{
|
{
|
||||||
return !impl.getFileDescriptor().valid();
|
return closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue