org.objectweb.jonathan.libs.resources.tcpip
Class IPv4ConnectionFactory

java.lang.Object
  extended by org.objectweb.jonathan.libs.resources.tcpip.IPv4ConnectionFactory
All Implemented Interfaces:
TcpIpConnectionMgr

public class IPv4ConnectionFactory
extends java.lang.Object
implements TcpIpConnectionMgr

Implementation of an IP V4 connection factory. When several IPv4 addresses are vailable on current host, you may set system property jonathan.connectionfactory.host to the one address you want to be used, or alternatively to a subnet number in the form d.d.d.d/n (subnet number/number of significant bits)


Field Summary
 int backlog
          Maximum length of the queue on incoming connect requests.
 java.lang.String localhost_name
           
 int SO_LINGER
          If >= 0, enables the SO_LINGER option with the specified linger time.
 int SO_TIMEOUT
          If >= 0, enables the SO_TIMEOUT option with the specified timeout (in ms). 0 means infinity (no timeout).
 boolean TCP_NODELAY
          If true, enables the TCP_NODELAY option.
 boolean use_address_as_name
          Indicates whether the names used to identify endpoints should be host names or host addresses.
 boolean verbose
          Indicates whether warning messages should be printed to stderr.
 
Constructor Summary
IPv4ConnectionFactory()
          Returns a new IPv4ConnectionFactory with default parameters.
IPv4ConnectionFactory(java.lang.String localhost_value, boolean verbose, int SO_LINGER, int SO_TIMEOUT, boolean TCP_NODELAY, int backlog, int max_retries, boolean use_address_as_name)
          Returns a new IPv4 connection factory
 
Method Summary
 java.lang.String getCanonicalHostName(java.lang.String hostname)
          Returns the canonical host name corresponding to hostname.
 IpConnection newCltConnection(java.lang.String host, int port, IpSession session)
          Builds a new client-side connection with the provided parameters.
protected  org.objectweb.jonathan.libs.resources.tcpip.IPv4ConnectionFactory.Connection newSrvConnection(java.net.Socket socket, IpSession session, java.lang.String host, int port)
          Builds a new server-side connection with the provided parameters.
 TcpIpSrvConnectionFactory newSrvConnectionFactory(int port)
          Returns a new server connection factory encapsulating a server socket on the provided port.
 void setVerbose(boolean verbose)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localhost_name

public java.lang.String localhost_name

verbose

public boolean verbose
Indicates whether warning messages should be printed to stderr.


use_address_as_name

public boolean use_address_as_name
Indicates whether the names used to identify endpoints should be host names or host addresses.


SO_LINGER

public int SO_LINGER
If >= 0, enables the SO_LINGER option with the specified linger time.


SO_TIMEOUT

public int SO_TIMEOUT
If >= 0, enables the SO_TIMEOUT option with the specified timeout (in ms). 0 means infinity (no timeout).


TCP_NODELAY

public boolean TCP_NODELAY
If true, enables the TCP_NODELAY option.


backlog

public int backlog
Maximum length of the queue on incoming connect requests.

Constructor Detail

IPv4ConnectionFactory

public IPv4ConnectionFactory()
                      throws JonathanException
Returns a new IPv4ConnectionFactory with default parameters.

Throws:
JonathanException - if something goes wrong.

IPv4ConnectionFactory

public IPv4ConnectionFactory(java.lang.String localhost_value,
                             boolean verbose,
                             int SO_LINGER,
                             int SO_TIMEOUT,
                             boolean TCP_NODELAY,
                             int backlog,
                             int max_retries,
                             boolean use_address_as_name)
                      throws JonathanException
Returns a new IPv4 connection factory

Parameters:
localhost_value - string representing the local machine (may be null)
verbose - indicates whether warning messages should be output on stderr
SO_LINGER - SO_LINGER parameter used to create sockets
SO_TIMEOUT - SO_TIMEOUT parameter used to create sockets
TCP_NODELAY - TCP_NODELAY parameter used to create sockets
backlog - backlog parameter used to create sockets
max_retries - maximum number of retries when creating a socket
use_address_as_name - use a.b.c.d adresses instead of DNS names
Throws:
JonathanException - if something goes wrong
Method Detail

setVerbose

public void setVerbose(boolean verbose)

newCltConnection

public IpConnection newCltConnection(java.lang.String host,
                                     int port,
                                     IpSession session)
                              throws JonathanException
Builds a new client-side connection with the provided parameters.

Specified by:
newCltConnection in interface TcpIpConnectionMgr
Parameters:
host - a host name;
port - a port number;
session - a TCP/IP session;
Returns:
a new client-side connection.
Throws:
JonathanException - if something goes wrong.

newSrvConnectionFactory

public TcpIpSrvConnectionFactory newSrvConnectionFactory(int port)
                                                  throws JonathanException
Returns a new server connection factory encapsulating a server socket on the provided port. If port = 0, an anonymous server socket is opened.

Specified by:
newSrvConnectionFactory in interface TcpIpConnectionMgr
Parameters:
port - the expected port of the server socket;
Returns:
a server connection factory.
Throws:
JonathanException - if an error occurs.

getCanonicalHostName

public java.lang.String getCanonicalHostName(java.lang.String hostname)
Returns the canonical host name corresponding to hostname. If use_address_as_name is true, the canonical host name is the string corresponding to the IP address, else it is the machine name.

Specified by:
getCanonicalHostName in interface TcpIpConnectionMgr
Parameters:
hostname - a host name.
Returns:
the canonical host name corresponding to hostname.

newSrvConnection

protected org.objectweb.jonathan.libs.resources.tcpip.IPv4ConnectionFactory.Connection newSrvConnection(java.net.Socket socket,
                                                                                                        IpSession session,
                                                                                                        java.lang.String host,
                                                                                                        int port)
                                                                                                 throws JonathanException
Builds a new server-side connection with the provided parameters.

Parameters:
socket - a TCP/IP socket;
session - a TCP/IP session;
host - a host name;
port - a port number;
Returns:
a new server-side connection.
Throws:
JonathanException - if something goes wrong.


Copyright © 2008 OW2 Consortium. All Rights Reserved.