+2003-01-10 Michael Koch <konqueror@gmx.de>
+
+ * java/net/DatagramSocket.java
+ (ch): Description added.
+ (remotePort): Initialize with -1.
+ (connect): Doesnt throws SocketException.
+ * java/net/MulticastSocket.java
+ (setInterface): Merge with Classpath.
+ * java/net/ServerSocket.java
+ (closed): New member variable.
+ (bind): Check if socket is closed.
+ (close): Close an associated channel too, set new value to closed.
+ (isBound): Reindented.
+ (isClosed): Implemented.
+ * java/net/Socket.java
+ (closed): New member variable.
+ (bind): Check if socket is closed.
+ (connect): Check if socket is closed.
+ (close): Close an associated channel too, set new value to closed.
+ (isClosed): Implemented.
+
2003-01-10 Michael Koch <konqueror@gmx.de>
* java/awt/DisplayMode.java
*/
DatagramSocketImpl impl;
+ /**
+ * The unique DatagramChannel object associated with this datagram socket,
+ * or null.
+ */
DatagramChannel ch;
/**
/**
* This is the port we are "connected" to
*/
- private int remotePort;
+ private int remotePort = -1;
/**
* Creates a DatagramSocket from a specified DatagramSocketImpl instance
* @since 1.2
*/
public void connect(InetAddress address, int port)
- throws SocketException
{
if (address == null)
throw new IllegalArgumentException ("Address may not be null");
if (sm != null)
sm.checkAccept(address.getHostName (), port);
+ try
+ {
impl.connect (address, port);
-
remoteAddress = address;
remotePort = port;
+ }
+ catch (SocketException e)
+ {
+ }
}
/**
/* MulticastSocket.java -- Class for using multicast sockets
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
/**
* Sets the interface to use for sending multicast packets.
*
- * @param inf The new interface to use
+ * @param addr The new interface to use.
*
- * @exception SocketException If an error occurs
+ * @exception SocketException If an error occurs.
+ *
+ * @since 1.4
*/
- public void setInterface(InetAddress inf) throws SocketException
+ public void setInterface(InetAddress addr) throws SocketException
{
- impl.setOption(SocketOptions.IP_MULTICAST_IF, inf);
+ impl.setOption(SocketOptions.IP_MULTICAST_IF, addr);
}
/**
*/
private ServerSocketChannel ch;
+ private boolean closed = false;
+
/**
* Constructor that simply sets the implementation.
*
*/
public void bind (SocketAddress endpoint, int backlog) throws IOException
{
+ if (closed)
+ throw new SocketException ("ServerSocket is closed");
+
if (impl == null)
throw new IOException ("Cannot initialize Socket implementation");
*/
public void close () throws IOException
{
- impl.close();
+ if (impl != null)
+ impl.close ();
+
+ if (ch != null)
+ ch.close ();
+
+ closed = true;
}
/**
*/
public boolean isClosed()
{
- // FIXME: implement this
- return false;
+ return closed;
}
/**
SocketChannel ch; // this field must have been set if created by SocketChannel
+ private boolean closed = false;
+
// Constructors
/**
*/
public void bind (SocketAddress bindpoint) throws IOException
{
+ if (closed)
+ throw new SocketException ("Socket is closed");
+
if ( !(bindpoint instanceof InetSocketAddress))
throw new IllegalArgumentException ();
public void connect (SocketAddress endpoint)
throws IOException
{
+ if (closed)
+ throw new SocketException ("Socket is closed");
+
if (! (endpoint instanceof InetSocketAddress))
throw new IllegalArgumentException ("Address type not supported");
public void connect (SocketAddress endpoint, int timeout)
throws IOException
{
+ if (closed)
+ throw new SocketException ("Socket is closed");
+
if (! (endpoint instanceof InetSocketAddress))
throw new IllegalArgumentException ("Address type not supported");
{
if (impl != null)
impl.close();
+
+ if (ch != null)
+ ch.close();
+
+ closed = true;
}
/**
*/
public boolean isClosed ()
{
- // FIXME: implement this.
- return false;
+ return closed;
}
/**