asynctcp
Class ConnectionManager

java.lang.Object
  extended by asynctcp.ConnectionManager

public class ConnectionManager
extends java.lang.Object

A class allowing management of connections for an ASyncTCP instance.

Author:
Michael Parker

Method Summary
 java.util.List<IncomingConnection> getIncomingConnections()
          Returns a list containing handles to all ASyncTCP connections established by a remote host.
 ASyncTCPListener getListener()
          Retrieves the listener for this ASyncTCP instance.
 java.util.List<OutgoingConnection> getOutgoingConnections()
          Returns a list containing handles to all ASyncTCP connections established by this host.
 int getPortNumber()
          Returns the port number on which this ASyncTCP instance is listening for new incoming connections.
 OutgoingConnection openConnection(AddressPortPair app, long timeout_ms)
          Begins establishing a new ASyncTCP connection to a remote host at the specified IP address and port.
 ASyncTCPListener setListener(ASyncTCPListener asl)
          Sets asl as the listener on this ASyncTCP instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

openConnection

public OutgoingConnection openConnection(AddressPortPair app,
                                         long timeout_ms)
Begins establishing a new ASyncTCP connection to a remote host at the specified IP address and port.

Parameters:
app - the IP address and port number of the remote host
timeout_ms - the maximum amount of time, in milliseconds, before it is assumed that the connection attempt has failed
Returns:
a handle to the connection through an OutgoingConnection object

getOutgoingConnections

public java.util.List<OutgoingConnection> getOutgoingConnections()
Returns a list containing handles to all ASyncTCP connections established by this host.

Returns:
a list containing all valid OutgoingConnection objects

getIncomingConnections

public java.util.List<IncomingConnection> getIncomingConnections()
Returns a list containing handles to all ASyncTCP connections established by a remote host.

Returns:
a list containing all valid IncomingConnection objects.

getListener

public ASyncTCPListener getListener()
Retrieves the listener for this ASyncTCP instance.

Returns:
the current listener for this ASyncTCP instance, or null if there is no listener

setListener

public ASyncTCPListener setListener(ASyncTCPListener asl)
Sets asl as the listener on this ASyncTCP instance. The listener can later be retrieved via the getListener method. Only one listener may be set at a time; invoking this method causes any previous listener to be discarded. The current listener may be discarded by passing in null.

Parameters:
asl - the new listener for this ASyncTCP instance
Returns:
the previous listener

getPortNumber

public int getPortNumber()
Returns the port number on which this ASyncTCP instance is listening for new incoming connections. If this method returns -1, then this instance is not listening on any port, and manages only outgoing connections.

Returns:
the port number on which this ASyncTCP instance listens for incoming connections