ionflux.org | Impressum

Ionflux::Tools::TCPRemotePeer Class Reference
[Network interface]

TCPRemotePeer. More...

#include <TCPRemotePeer.hpp>

Inheritance diagram for Ionflux::Tools::TCPRemotePeer:

Inheritance graph
[legend]
Collaboration diagram for Ionflux::Tools::TCPRemotePeer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TCPRemotePeer ()
 Constructor.
 TCPRemotePeer (int initID)
 Constructor.
virtual ~TCPRemotePeer ()
 Destructor.
virtual bool receive ()
 Receive data.
virtual bool send (const std::string &bytes)
 Send data.
virtual void setID (int newID)
 Set ID.
virtual void setProtocolState (int newProtocolState)
 Set protocol state.
virtual void setMessageHandler (MessageHandler *newMessageHandler)
 Set message handler.
virtual int getID ()
 Get ID of the peer.
virtual TCPSocketgetSocket ()
 Get socket.
virtual AuthDatagetAuthData ()
 Get authentication data.
virtual std::string & getRecvBuf ()
 Get receive buffer.
virtual unsigned int removeRecvBytes (unsigned int numBytes)
 Remove bytes from receive buffer.
virtual void clearRecvBuf ()
 Clear the receive buffer.
virtual int getProtocolState ()
 Get protocol state.
virtual void * getData ()
 Get data.
virtual unsigned int getDataSize ()
 Get size of data.
virtual MessagegetMessage ()
 Get message.
virtual NodegetCache ()
 Get cache.
virtual void dump (Message &msg)
 Dump message.

Static Public Attributes

static const int ID_NOT_SET = -1
 Peer ID: Not set.
static const int PROTOCOL_STATE_UNDEFINED = -1
 Protocol state: Undefined.

Protected Attributes

int id
 Numerical ID of the peer.
TCPSocket socket
 Socket used to communicate with the remote peer.
std::string recvBuf
 Receive buffer.
int protocolState
 Protocol state.
void * data
 Peer data.
unsigned int dataSize
 Size of data.
Messagemessage
 Message.
MessageHandlermessageHandler
 Message handler.
AuthData auth
 Authentication data.
Nodecache
 Message data cache.

Detailed Description

TCPRemotePeer.

The remote peer of a TCP connection.


Constructor & Destructor Documentation

Ionflux::Tools::TCPRemotePeer::TCPRemotePeer  ) 
 

Constructor.

Construct new TCPRemotePeer object.

Ionflux::Tools::TCPRemotePeer::TCPRemotePeer int  initID  ) 
 

Constructor.

Construct new TCPRemotePeer object.

Parameters:
initID Numerical ID of the peer.

Ionflux::Tools::TCPRemotePeer::~TCPRemotePeer  )  [virtual]
 

Destructor.

Destruct TCPRemotePeer object.


Member Function Documentation

void Ionflux::Tools::TCPRemotePeer::clearRecvBuf  )  [virtual]
 

Clear the receive buffer.

void Ionflux::Tools::TCPRemotePeer::dump Message msg  )  [virtual]
 

Dump message.

Pass a message to the object for handling.

Parameters:
msg The message to be dumped.

Implements Ionflux::Tools::MessageDump.

AuthData & Ionflux::Tools::TCPRemotePeer::getAuthData  )  [virtual]
 

Get authentication data.

Get the authentication data for this peer.

Returns:
Authentication data used for this peer.

Node * Ionflux::Tools::TCPRemotePeer::getCache  )  [virtual]
 

Get cache.

Get a node in which message data (or other arbitrary data) can be stored.

Returns:
Pointer to cache node.

void * Ionflux::Tools::TCPRemotePeer::getData  )  [virtual]
 

Get data.

Returns:
Pointer to data.

unsigned int Ionflux::Tools::TCPRemotePeer::getDataSize  )  [virtual]
 

Get size of data.

Returns:
Size of data.

int Ionflux::Tools::TCPRemotePeer::getID  )  [virtual]
 

Get ID of the peer.

Returns:
Numerical ID of the peer.

Message * Ionflux::Tools::TCPRemotePeer::getMessage  )  [virtual]
 

Get message.

Returns:
Pointer to a message object, or 0 if message handling has not been initialized.

int Ionflux::Tools::TCPRemotePeer::getProtocolState  )  [virtual]
 

Get protocol state.

Returns:
Current protocol state.

std::string & Ionflux::Tools::TCPRemotePeer::getRecvBuf  )  [virtual]
 

Get receive buffer.

Returns:
Receive buffer.

TCPSocket & Ionflux::Tools::TCPRemotePeer::getSocket  )  [virtual]
 

Get socket.

Get the socket used to communicate with the remote peer.

Returns:
Socket used to communicate with the remote peer.

bool Ionflux::Tools::TCPRemotePeer::receive  )  [virtual]
 

Receive data.

Receives data from the socket. The data will be appended to the receive buffer.

Returns:
true on success, false otherwise.

unsigned int Ionflux::Tools::TCPRemotePeer::removeRecvBytes unsigned int  numBytes  )  [virtual]
 

Remove bytes from receive buffer.

Removes the first numBytes bytes from the receive buffer.

Returns:
Number of bytes left in the receive buffer.

bool Ionflux::Tools::TCPRemotePeer::send const std::string &  bytes  )  [virtual]
 

Send data.

Send data over the socket.

Parameters:
bytes The data to be sent.
Returns:
true on success, false otherwise.

void Ionflux::Tools::TCPRemotePeer::setID int  newID  )  [virtual]
 

Set ID.

Sets the numerical ID of this peer.

Parameters:
newID Numerical ID of the peer.

void Ionflux::Tools::TCPRemotePeer::setMessageHandler MessageHandler newMessageHandler  )  [virtual]
 

Set message handler.

Set the message handler to be used for message handling.

Note:
If you set this to a non-null value, the receive buffer will be disabled. Instead, all incoming data will be dumped into the message object of the remote peer.
Parameters:
newMessageHandler Pointer to a message handler.

void Ionflux::Tools::TCPRemotePeer::setProtocolState int  newProtocolState  )  [virtual]
 

Set protocol state.

Sets the current protocol state. Use this to set the protocol state for implementations of stateful protocols.

Parameters:
newProtocolState The new protocol state.


Member Data Documentation

AuthData Ionflux::Tools::TCPRemotePeer::auth [protected]
 

Authentication data.

Node* Ionflux::Tools::TCPRemotePeer::cache [protected]
 

Message data cache.

Can be used by the application to store message data (or other arbitrary data).

void* Ionflux::Tools::TCPRemotePeer::data [protected]
 

Peer data.

You can use this to associate arbitrary data with a remote peer.

unsigned int Ionflux::Tools::TCPRemotePeer::dataSize [protected]
 

Size of data.

int Ionflux::Tools::TCPRemotePeer::id [protected]
 

Numerical ID of the peer.

const int Ionflux::Tools::TCPRemotePeer::ID_NOT_SET = -1 [static]
 

Peer ID: Not set.

Message* Ionflux::Tools::TCPRemotePeer::message [protected]
 

Message.

This will be used for processing incoming data if you set a non-null message handler.

MessageHandler* Ionflux::Tools::TCPRemotePeer::messageHandler [protected]
 

Message handler.

const int Ionflux::Tools::TCPRemotePeer::PROTOCOL_STATE_UNDEFINED = -1 [static]
 

Protocol state: Undefined.

int Ionflux::Tools::TCPRemotePeer::protocolState [protected]
 

Protocol state.

You can use this to keep track of protocol state in stateful protocols.

std::string Ionflux::Tools::TCPRemotePeer::recvBuf [protected]
 

Receive buffer.

TCPSocket Ionflux::Tools::TCPRemotePeer::socket [protected]
 

Socket used to communicate with the remote peer.


The documentation for this class was generated from the following files:
Generated on Tue Mar 14 21:10:59 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6