us.ihmc.mockets
Class StreamServerMocket

java.lang.Object
  extended by us.ihmc.mockets.StreamServerMocket

public class StreamServerMocket
extends java.lang.Object

The ServerMocket class represents an endpoint for mockets that is capable of receiving incoming connections. This class is designed to be a drop-in replacement for the Socket class in the Java Platform API.


Constructor Summary
StreamServerMocket(int port)
          Construct a new server mocket that listens for incoming connections on the specified port.
StreamServerMocket(java.net.SocketAddress sockAddress)
          Construct a new server mocket that listens for incoming connections on the specified SocketAddress.
 
Method Summary
 StreamMocket accept()
          Accept a new connection and return an instance of Mocket that represents the local endpoint for the new connection.
 void close()
          Close the server mocket and no longer accept new incoming connections.
protected  void finalize()
           
 int getLocalPort()
          Returns the port on which this socket is listening.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamServerMocket

public StreamServerMocket(java.net.SocketAddress sockAddress)
                   throws java.io.IOException
Construct a new server mocket that listens for incoming connections on the specified SocketAddress.

Parameters:
sockAddress - the address to use.
Throws:
java.io.IOException - if the specified port is in use.

StreamServerMocket

public StreamServerMocket(int port)
                   throws java.io.IOException
Construct a new server mocket that listens for incoming connections on the specified port.

Parameters:
port - the port number to use.
Throws:
java.io.IOException - if the specified port is in use.
Method Detail

getLocalPort

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


finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

accept

public StreamMocket accept()
                    throws java.io.IOException
Accept a new connection and return an instance of Mocket that represents the local endpoint for the new connection. The method will block until a new connection is received.

Returns:
a new Mocket instance that represents the new connection
Throws:
java.io.IOException - if there was a problem in accepting the connection

close

public void close()
Close the server mocket and no longer accept new incoming connections.