jcontrol.net
Class ServerSocket

java.lang.Object
  extended by jcontrol.net.ServerSocket

public class ServerSocket
extends Object

JControl - ServerSocket Implementation


Constructor Summary
ServerSocket(int port)
          Creates a server socket, bound to the specified port.
 
Method Summary
 Socket accept()
          Listens for a connection to be made to this socket and accepts it.
 void close()
          Closes this socket.
protected  void finalize()
          Free internal data structures used by this serversocket object.
 int getLocalPort()
          Returns the port on which this socket is listening.
 boolean isClosed()
          Returns the closed state of the ServerSocket.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Constructor Detail

ServerSocket

public ServerSocket(int port)
             throws IOException
Creates a server socket, bound to the specified port. The maximum queue length for incoming connection indications (a request to connect) is set to 10. If a connection indication arrives when the queue is full, the connection is refused.

Parameters:
port - - the port number, or 0 to use any free port.
Throws:
IOException - - if an I/O error occurs when opening the socket.
Method Detail

accept

public Socket accept()
              throws IOException
Listens for a connection to be made to this socket and accepts it. The method blocks until a connection is made. If connection is made, a new Socket s is created and returned.

Returns:
the new Socket
Throws:
IOException - if an I/O error occurs when waiting for a connection. if the socket was closed while waiting for connection

close

public void close()
           throws IOException
Closes this socket. If any thread is blocked by accept(), the method will leaved by throwing an InterruptedException. If this socket has an associated channel then the channel is closed as well.

Throws:
IOException - if an I/O error occurs when closing the socket.

isClosed

public boolean isClosed()
Returns the closed state of the ServerSocket.

Returns:
true if the socket has been closed

getLocalPort

public int getLocalPort()
Returns the port on which this socket is listening.

Returns:
the port number to which this socket is listening or -1 if the socket is not bound yet.

finalize

protected void finalize()
Free internal data structures used by this serversocket object.