com.googlecode.mobilityrpc.network
Class ConnectionId

java.lang.Object
  extended by com.googlecode.mobilityrpc.network.ConnectionId

public class ConnectionId
extends Object

Identifies the endpoint (address + port) of a connection. Conceptually very similar to InetSocketAddress.

Connection ids can be supplied to the ConnectionManager to request a connection to a specific port on a remote machine, or they can be supplied to the execute methods in MobilitySession which will create an outgoing connection automatically.

Connection ids are also often used in the framework itself, passed between components in ConnectionId-message pairs, to indicate the connection from which a message was received or to which is addressed.

Auxiliary Connections
In addition to encapsulating an address + port combination, connection ids optionally also encapsulate an "auxiliary connection id", which is a number greater than zero chosen by the application to allow it to establish and distinguish between potentially multiple auxiliary connections to a remote machine.

Note that auxiliary connections are not required or recommended for most applications. In fact support for auxiliary connections exists to work around limitations in TCP connections on some types of networks or specialist applications only. A single multiplexed connection will normally be established by default, and so establishing multiple connections is unlikely to improve bandwidth utilisation, except on very high latency connections (connections with high BDP, bandwidth-delay product).

To create an auxiliary connection, the application may create a connection id referring to a remote machine as normal, but additionally supply an auxiliary connection id greater than zero to the constructor. It can then send objects to the remote machine using this connection id as normal; the library (ConnectionManager) will create or reuse the auxiliary connection indicated automatically.

Note that auxiliary connection ids are not transmitted to the remote machine. They are useful within the local application only. The default connection to a remote machine will always have auxiliary connection id 0 on both sides. On the remote machine, when incoming auxiliary connections are accepted, they will be assigned unique negative auxiliary connection ids on that machine.

Author:
Niall Gallagher

Constructor Summary
ConnectionId(String address, int port)
          Creates a connection id which uses the primary connection to the address and port specified.
ConnectionId(String address, int port, int auxiliaryConnectionId)
          Creates a connection id which uses an auxiliary connection to the address and port specified.
 
Method Summary
 boolean equals(Object o)
           
 String getAddress()
           
 int getAuxiliaryConnectionId()
           
 int getPort()
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionId

public ConnectionId(String address,
                    int port)
Creates a connection id which uses the primary connection to the address and port specified.

Parameters:
address - The ip address or name of the machine to connect to
port - The port on which the machine is running a connection listener

ConnectionId

public ConnectionId(String address,
                    int port,
                    int auxiliaryConnectionId)
Creates a connection id which uses an auxiliary connection to the address and port specified.

Parameters:
address - The ip address or name of the machine to connect to
port - The port on which the machine is running a connection listener
auxiliaryConnectionId - A number greater than zero chosen by the application to allow it to distinguish between potentially multiple auxiliary connections
Method Detail

getAddress

public String getAddress()

getPort

public int getPort()

getAuxiliaryConnectionId

public int getAuxiliaryConnectionId()

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.