IBR-DTNSuite  0.10
dtn::streams::StreamConnection Class Reference

#include <StreamConnection.h>

Inheritance diagram for dtn::streams::StreamConnection:
Inheritance graph
Collaboration diagram for dtn::streams::StreamConnection:
Collaboration graph

Classes

class  Callback
 
class  StreamClosedException
 
class  StreamErrorException
 
class  StreamShutdownException
 
class  TransmissionInterruptedException
 

Public Types

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, const dtn::data::Length buffer_size=4096)
 
virtual ~StreamConnection ()
 
void handshake (const dtn::data::EID &eid, const dtn::data::Timeout &timeout, const dtn::data::Bitset< StreamContactHeader::HEADER_BITS > &flags)
 
void shutdown (ConnectionShutdownCases csc=CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN)
 
void reject ()
 
void keepalive ()
 
void enableIdleTimeout (const dtn::data::Timeout &seconds)
 
void setMonitor (bool val)
 
void resetMonitorStats ()
 
size_t getMonitorStat (int index)
 

Detailed Description

Definition at line 43 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 46 of file StreamConnection.h.

Constructor & Destructor Documentation

dtn::streams::StreamConnection::StreamConnection ( StreamConnection::Callback cb,
iostream &  stream,
const dtn::data::Length  buffer_size = 4096 
)

Constructor of the StreamConnection class

Parameters
cbCallback object for events of this stream
streamThe underlying stream object

Definition at line 36 of file StreamConnection.cpp.

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

Destructor of the StreamConnection class

Returns

Definition at line 41 of file StreamConnection.cpp.

Member Function Documentation

void dtn::streams::StreamConnection::enableIdleTimeout ( const dtn::data::Timeout seconds)

enables the idle timeout thread

Parameters
seconds

Definition at line 158 of file StreamConnection.cpp.

size_t dtn::streams::StreamConnection::getMonitorStat ( int  index)

Definition at line 174 of file StreamConnection.cpp.

void dtn::streams::StreamConnection::handshake ( const dtn::data::EID eid,
const dtn::data::Timeout timeout,
const dtn::data::Bitset< StreamContactHeader::HEADER_BITS > &  flags 
)

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

Parameters
eidThe local address of this node.
timeoutThe desired timeout for this connection.

Definition at line 45 of file StreamConnection.cpp.

References dtn::streams::StreamContactHeader::_flags, dtn::streams::StreamContactHeader::_keepalive, and dtn::streams::StreamConnection::Callback::eventConnectionUp().

Referenced by dtn::api::Client::connect(), and dtn::api::BinaryStreamClient::run().

Here is the call graph for this function:

void dtn::streams::StreamConnection::keepalive ( )

send a keepalive

Definition at line 68 of file StreamConnection.cpp.

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

This method rejects the currently transmitted bundle

Definition at line 63 of file StreamConnection.cpp.

void dtn::streams::StreamConnection::resetMonitorStats ( )

Definition at line 168 of file StreamConnection.cpp.

void dtn::streams::StreamConnection::setMonitor ( bool  val)

traffic monitoring

Definition at line 163 of file StreamConnection.cpp.

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
cscThe case of the requested shutdown.

Definition at line 73 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::BinaryStreamClient::__cancellation(), dtn::api::Client::abort(), dtn::api::Client::close(), and dtn::api::BinaryStreamClient::run().

Here is the call graph for this function:


The documentation for this class was generated from the following files: