mobnet
Class ServerSocket

java.lang.Object
  extended bymobnet.ServerSocket

public class ServerSocket
extends java.lang.Object

ServerSocket.java MobNet ServerSocket implementation

Author:
Avi TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Constructor Summary
ServerSocket(int port)
          Constructor for ServerSocket binds the ServerSocket to the specified port
 
Method Summary
 Socket accept()
          Listens for a connection to be made to this socket and accepts it.
 void addConnection(PortIP pip)
          This method is used by the Singleton Manager.
 int getPort()
          Returns the port which this ServerSocket is bound to.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerSocket

public ServerSocket(int port)
             throws java.io.IOException
Constructor for ServerSocket binds the ServerSocket to the specified port

Parameters:
port - The port to which the ServerSocker is bound.
Throws:
java.io.IOException
Method Detail

accept

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

Returns:
the new Socket
Throws:
java.io.IOException

addConnection

public void addConnection(PortIP pip)
This method is used by the Singleton Manager. When a client creates a Socket, it then creates a PortIP object which containts the clients port, IP and reference to its Socket. The PortIP object is then into a queue which the ServerSocket will then service by use of accept()

Parameters:
pip - PortIP object which containts the clients port, IP and reference to its Socket.

getPort

public int getPort()
Returns the port which this ServerSocket is bound to.

Returns:
The port which this ServerSocket is bound to.