dtn::streams::StreamConnection Class Reference

#include <StreamConnection.h>

Inheritance diagram for dtn::streams::StreamConnection:
dtn::api::Client

List of all members.

Classes

class  Callback
class  StreamBuffer
class  StreamClosedException
class  StreamErrorException
class  StreamShutdownException
class  TransmissionInterruptedException

Public Types

enum  ConnectionState { CONNECTION_INITIAL = 0, CONNECTION_CONNECTED = 1, CONNECTION_SHUTDOWN = 2, CONNECTION_CLOSED = 3 }
enum  ConnectionShutdownCases {
  CONNECTION_SHUTDOWN_NOTSET = 0, CONNECTION_SHUTDOWN_IDLE = 1, CONNECTION_SHUTDOWN_ERROR = 2, CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN = 3,
  CONNECTION_SHUTDOWN_NODE_TIMEOUT = 4, CONNECTION_SHUTDOWN_PEER_SHUTDOWN = 5
}

Public Member Functions

 StreamConnection (StreamConnection::Callback &cb, iostream &stream)
virtual ~StreamConnection ()
void handshake (const dtn::data::EID &eid, const size_t timeout=10, const char flags=0)
bool isConnected ()
void wait (const size_t timeout=0)
void shutdown (ConnectionShutdownCases csc=CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN)
void reject ()

Detailed Description

Definition at line 28 of file StreamConnection.h.


Member Enumeration Documentation

Enumerator:
CONNECTION_SHUTDOWN_NOTSET 
CONNECTION_SHUTDOWN_IDLE 
CONNECTION_SHUTDOWN_ERROR 
CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN 
CONNECTION_SHUTDOWN_NODE_TIMEOUT 
CONNECTION_SHUTDOWN_PEER_SHUTDOWN 

Definition at line 39 of file StreamConnection.h.

Enumerator:
CONNECTION_INITIAL 
CONNECTION_CONNECTED 
CONNECTION_SHUTDOWN 
CONNECTION_CLOSED 

Definition at line 31 of file StreamConnection.h.


Constructor & Destructor Documentation

dtn::streams::StreamConnection::StreamConnection ( StreamConnection::Callback cb,
iostream &  stream 
)

Constructor of the StreamConnection class

Parameters:
cb Callback object for events of this stream
stream The underlying stream object

Definition at line 22 of file StreamConnection.cpp.

dtn::streams::StreamConnection::~StreamConnection (  )  [virtual]

Destructor of the StreamConnection class

Returns:

Definition at line 28 of file StreamConnection.cpp.


Member Function Documentation

void dtn::streams::StreamConnection::handshake ( const dtn::data::EID eid,
const size_t  timeout = 10,
const char  flags = 0 
)

Do a handshake with the other peer. This operation is needed to communicate.

Parameters:
eid The local address of this node.
timeout The desired timeout for this connection.

Definition at line 32 of file StreamConnection.cpp.

References dtn::streams::StreamContactHeader::_flags, dtn::streams::StreamContactHeader::_keepalive, CONNECTION_CONNECTED, dtn::streams::StreamConnection::Callback::eventConnectionUp(), and ibrcommon::StatefulConditional< T, block >::setState().

Referenced by dtn::api::Client::connect(), dtn::net::TCPConvergenceLayer::TCPConnection::handshake(), and dtn::daemon::ClientHandler::run().

bool dtn::streams::StreamConnection::isConnected (  ) 

Returns a variable which tells the connection status.

Returns:
True, if connected.

Reimplemented in dtn::api::Client.

Definition at line 143 of file StreamConnection.cpp.

References CONNECTION_CLOSED, CONNECTION_INITIAL, and ibrcommon::StatefulConditional< T, block >::getState().

Referenced by dtn::daemon::ClientHandler::isConnected().

void dtn::streams::StreamConnection::reject (  ) 

This method rejects the currently transmitted bundle

Definition at line 59 of file StreamConnection.cpp.

Referenced by dtn::net::TCPConvergenceLayer::TCPConnection::rejectTransmission().

void dtn::streams::StreamConnection::shutdown ( ConnectionShutdownCases  csc = CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN  ) 

This method shutdown the whole connection handling process. To differ between the expected cases of disconnection a connection shutdown case is needed.

CONNECTION_SHUTDOWN_IDLE The connection was idle and should go down now.

CONNECTION_SHUTDOWN_ERROR A critical tcp error occured and the connection is closed.

CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN The connection is ok, but a shutdown is requested from anywhere.

CONNECTION_SHUTDOWN_NODE_TIMEOUT The node of this connection is gone. So shutdown this connection.

CONNECTION_SHUTDOWN_PEER_SHUTDOWN The peer has shutdown this connection by a shutdown message.

Parameters:
csc The case of the requested shutdown.

Definition at line 77 of file StreamConnection.cpp.

References CONNECTION_SHUTDOWN_ERROR, CONNECTION_SHUTDOWN_IDLE, CONNECTION_SHUTDOWN_NODE_TIMEOUT, CONNECTION_SHUTDOWN_NOTSET, CONNECTION_SHUTDOWN_PEER_SHUTDOWN, CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN, dtn::streams::StreamConnection::Callback::eventConnectionDown(), dtn::streams::StreamConnection::Callback::eventError(), dtn::streams::StreamConnection::Callback::eventShutdown(), dtn::streams::StreamConnection::Callback::eventTimeout(), dtn::streams::StreamDataSegment::MSG_SHUTDOWN_IDLE_TIMEOUT, and dtn::streams::StreamDataSegment::MSG_SHUTDOWN_NONE.

Referenced by dtn::api::Client::close(), dtn::daemon::ClientHandler::run(), dtn::net::TCPConvergenceLayer::TCPConnection::shutdown(), and dtn::daemon::ClientHandler::shutdown().

void dtn::streams::StreamConnection::wait ( const size_t  timeout = 0  ) 

The documentation for this class was generated from the following files:
Generated on Mon Aug 23 08:13:00 2010 for IBR-DTNSuite by  doxygen 1.6.3