org.iperg.part.core
Class IpTcpConnection

java.lang.Object
  extended by org.iperg.part.core.IpConnection
      extended by org.iperg.part.core.IpTcpConnection
All Implemented Interfaces:
java.lang.Runnable

public class IpTcpConnection
extends IpConnection
implements java.lang.Runnable

The IpTcpConnection class implements a PART Tcp protocol connection.

Version:
1.0.0 Initial version
Author:
Olov Stahl - olovs@sics.se

Field Summary
 
Fields inherited from class org.iperg.part.core.IpConnection
BROKEN, CLOSED_LOCALLY, CLOSED_REMOTELY, CONNECTED, CONNECTING, LISTEN, UNCONNECTED
 
Constructor Summary
IpTcpConnection()
          Create an unconnected Tcp connection object
 
Method Summary
protected  boolean _outgoingEventsAreCached()
          Check if events sent via the send method are cached locally.
protected  void close()
          Close the connection
protected  IpConnection protoAccept()
          Accept a incoming connection on the server socket opened by protoListen.
protected  void protoConnect(IpUrl url)
          Connect to a network address represented by an url.
protected  IpUrl protoListen(IpUrl url)
          Start listening for incoming connections on a local network address represented by an url.
 
Methods inherited from class org.iperg.part.core.IpConnection
_send, getConnectionUrl, getRemoteProcessId, getSilence, getStatus, getTotalBytesReceived, getTotalBytesSent, getUrl, notifyBrokenConnection, notifyBytesReceived, notifyBytesSent, notifyReceivedEvent, run, setInputStream, setOutputStream, setUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

IpTcpConnection

public IpTcpConnection()
Create an unconnected Tcp connection object

Method Detail

protoConnect

protected void protoConnect(IpUrl url)
                     throws IpInvalidUrlException,
                            java.io.IOException
Connect to a network address represented by an url. The url syntax should be 'tcp://host:port'.

Specified by:
protoConnect in class IpConnection
Parameters:
url - A url representing a remote address
Throws:
IpInvalidUrlException - if the url protocol matches the connection factory protocol but url is somehow invalid, e.g., doesn't identify a remote address
java.io.IOException - if a factory specific error occured

protoListen

protected IpUrl protoListen(IpUrl url)
                     throws IpInvalidUrlException,
                            java.io.IOException
Start listening for incoming connections on a local network address represented by an url. The url syntax should be 'tcp://host:port' or 'tcp://:port'. If host is part of url, it has to identify the local host. If a remote host is given, an InvalidAddressException is generated.

Specified by:
protoListen in class IpConnection
Parameters:
url - A url identifying a local address
Returns:
A url that a remote process can use to connect to the local address
Throws:
IpInvalidUrlException - if the url parameter is invalid, e.g., doesn't identify a local address
java.io.IOException - if a protocol specific error occured

protoAccept

protected IpConnection protoAccept()
                            throws java.io.IOException
Accept a incoming connection on the server socket opened by protoListen. Is called by IpConnection.

Specified by:
protoAccept in class IpConnection
Throws:
java.io.IOException

close

protected void close()
              throws java.io.IOException
Close the connection

Specified by:
close in class IpConnection
Throws:
java.io.IOException - if the close failed for some reason

_outgoingEventsAreCached

protected boolean _outgoingEventsAreCached()
Check if events sent via the send method are cached locally.

Specified by:
_outgoingEventsAreCached in class IpConnection