org.jcsp.net2.tcpip
Class TCPIPLink

java.lang.Object
  extended by org.jcsp.net2.Link
      extended by org.jcsp.net2.tcpip.TCPIPLink
All Implemented Interfaces:
CSProcess

public final class TCPIPLink
extends Link

A concrete implementation of a Link that operates over a TCP/IP based socket connection. For information on Link, see the relative documentation.

It is perfectly possible for a user to create a TCPIPLink without going through the standard LinkFactory approach, although this is not recommended. For example:

TCPIPLink link = new TCPIPLink(address);
link.connect(); link.registerLink();
new ProcessManager(link).start();

Can be achieved using the LinkFactory:

link = LinkFactory.getLink(address);

The LinkFactory will create and start the Link automatically if required.

Author:
Kevin Chalmers
See Also:
Link, TCPIPNodeAddress

Field Summary
static int BUFFER_SIZE
          Defines the size of the buffer to place on the incoming and outgoing streams.
static boolean NAGLE
          Flag to determine whether the Nagle algorithm should be activated.
 
Fields inherited from class org.jcsp.net2.Link
connected, LINK_PRIORITY, priority, remoteID, rxStream, txStream
 
Constructor Summary
TCPIPLink(TCPIPNodeAddress address)
          Creates a new TCPIPLink
 
Method Summary
 boolean connect()
          Connects the Link to the remote Node.
protected  boolean createResources()
          Creates any required resources.
protected  void destroyResources()
          Destroys any resources used by the Link
 NodeAddress getRemoteAddress()
          Gets the NodeAddress of the Node that this Link is connected to
 
Methods inherited from class org.jcsp.net2.Link
getRemoteNodeID, getTxChannel, lostLink, registerLink, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static int BUFFER_SIZE
Defines the size of the buffer to place on the incoming and outgoing streams. This is a rather large size, and for certain implementations, this may be reduced. It is unlikely that any sent object will be this large.


NAGLE

public static boolean NAGLE
Flag to determine whether the Nagle algorithm should be activated. Default is false (off).

Constructor Detail

TCPIPLink

public TCPIPLink(TCPIPNodeAddress address)
          throws JCSPNetworkException
Creates a new TCPIPLink

Parameters:
address - The address of the remote Node to connect to
Throws:
JCSPNetworkException - Thrown if something goes wrong during the creation process
Method Detail

connect

public boolean connect()
                throws JCSPNetworkException
Connects the Link to the remote Node. Exchanges the NodeIDs

Specified by:
connect in class Link
Returns:
True if the Link successfully connected to the remote Link
Throws:
JCSPNetworkException - Thrown if something goes wrong during the connection

createResources

protected boolean createResources()
                           throws JCSPNetworkException
Creates any required resources. For TCP/IP there is none.

Specified by:
createResources in class Link
Returns:
True if all resources were created OK. Always the case in TCP/IP
Throws:
JCSPNetworkException - Thrown if anything goes wrong during the creation process.

destroyResources

protected void destroyResources()
Destroys any resources used by the Link

Specified by:
destroyResources in class Link

getRemoteAddress

public NodeAddress getRemoteAddress()
Gets the NodeAddress of the Node that this Link is connected to

Returns:
The NodeAddress of the remotely connected Node


Copyright © 1996-2012. All Rights Reserved.