ymsg.network
Class DirectConnectionHandler

Object
  extended byConnectionHandler
      extended byDirectConnectionHandler
Direct Known Subclasses:
SOCKSConnectionHandler

public class DirectConnectionHandler
extends ConnectionHandler

Connection handler for direct connections to Yahoo. Pass this class into the Session constructor to create a session which has no firewall or proxy requirements.

There are two system properties which alter the target of a connection. ymsg.network.directHost can be used to set the host to which the connection will be made. ymsg.network.directPorts can be used to set a comma-separated-list of ports to be tried in order (the first number on this list is treated as the primary port). In reality is it highly unlikely that these properties should need to be changed from their defaults: scs.msg.yahoo.com and 5050,23,25,80.

Since:
1.0

Constructor Summary
DirectConnectionHandler()
          Connect to the default host and port, or try all the fallback ports if the default port does not respond.
DirectConnectionHandler(boolean fl)
          Connect to the default host and port, but will not resort to fallback ports if the parameter is true.
DirectConnectionHandler(int p)
          Connect to the default host with the specified port, and will not resort the fallback.
DirectConnectionHandler(String h, int p)
          Connect to a specific host and port.
 
Method Summary
 String getHost()
          Returns the actual host name used for this connection.
 int getPort()
          Returns the actual port number used for this connection.
 String toString()
          Returns the string representation of this object.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectConnectionHandler

public DirectConnectionHandler(String h,
                               int p)
Connect to a specific host and port. No fallback ports will be used if the specified port fails.

Parameters:
h - host
p - port number
Since:
1.0

DirectConnectionHandler

public DirectConnectionHandler(int p)
Connect to the default host with the specified port, and will not resort the fallback. This method is handy if you with to connect to a specific port which is not the default.

For example, having initially used the default constructor (or the boolean constructor, set to true) to employ fallback ports until a clear path is found, the application then may use getPort to discover which port was actually successful, storing this information in a configuration file. When restarted, the application can then attempt to direct traffic straight to this port, avoiding the lenghty trial-and-error process.

Parameters:
p - port number
Since:
1.0

DirectConnectionHandler

public DirectConnectionHandler(boolean fl)
Connect to the default host and port, but will not resort to fallback ports if the parameter is true. When parameter is set to false, this has the same effect as the default constructor.

Parameters:
fl - false tries only the default port
Since:
1.0

DirectConnectionHandler

public DirectConnectionHandler()
Connect to the default host and port, or try all the fallback ports if the default port does not respond.

Since:
1.0
Method Detail

getHost

public String getHost()
Returns the actual host name used for this connection.

Returns:
host name
Since:
1.0

getPort

public int getPort()
Returns the actual port number used for this connection.

Returns:
port number
Since:
1.0

toString

public String toString()
Returns the string representation of this object.

Returns:
object as a string