+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>
* configure.in: Added check for memory mapping of files.
*/
private int remotePort = -1;
+ /**
+ * Indicates when the socket is closed.
+ */
+ private boolean closed = false;
+
/**
* Creates a DatagramSocket from a specified DatagramSocketImpl instance
*
*/
public void close()
{
- impl.close();
- remoteAddress = null;
- remotePort = -1;
+ if (!closed)
+ {
+ impl.close();
+ remoteAddress = null;
+ remotePort = -1;
+ closed = true;
+ }
}
/**
*/
public InetAddress getInetAddress()
{
- if (!isConnected ())
- return null;
-
return remoteAddress;
}
*/
public int getPort()
{
- if (!isConnected ())
- return -1;
-
return remotePort;
}
// s.checkConnect("localhost", -1);
try
{
- return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR);
+ return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR);
}
catch (SocketException ex)
{
try
{
- return InetAddress.getLocalHost();
+ return InetAddress.getLocalHost();
}
catch (UnknownHostException ex)
{
- // FIXME: This should never happen, so how can we avoid this construct?
- return null;
+ return null;
}
}
/**
* 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.
*
* @since 1.2
public void disconnect()
{
impl.disconnect();
+ remoteAddress = null;
+ remotePort = -1;
}
/**
*/
public boolean isClosed()
{
- return !impl.getFileDescriptor().valid();
+ return closed;
}
/**