com.ch.odi.net
Class PortListener

java.lang.Object
  |
  +--com.ch.odi.net.PortListener
Direct Known Subclasses:
PortListenerThread

public class PortListener
extends Object

Description: This object listens on a port and passes incoming connections to a custom handler object. This is typically used by server side applications.


Constructor Summary
PortListener()
          Deprecated. You should not create empty PortListeners
PortListener(int port, ConnectionHandler handler)
          Creates a new PortListener
 
Method Summary
 void listen()
          Starts listening on the port.
 void setConnectionHandler(ConnectionHandler handler)
          Deprecated. You should not change the connection handler
 void setPort(int port)
          Deprecated. You should not change the port
 void stopListening()
          Stops listening on the port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortListener

public PortListener()
Deprecated. You should not create empty PortListeners

Creates new PortListener

PortListener

public PortListener(int port,
                    ConnectionHandler handler)
Creates a new PortListener
Parameters:
port - The TCP port to wait for connections to
handler - The ConnectionHandler object that will take care of incoming connections
Method Detail

setConnectionHandler

public void setConnectionHandler(ConnectionHandler handler)
Deprecated. You should not change the connection handler

Sets the connection handler

setPort

public void setPort(int port)
Deprecated. You should not change the port

Sets the port

stopListening

public void stopListening()
Stops listening on the port.

listen

public void listen()
            throws IOException
Starts listening on the port. Incoming connections are passed to the connection handler. The method does not return until the ConnectionHandler's isStopped method returns true.