CTransport

Name

CTransport -- Abstract base class for data transport objects.

Synopsis


#include <sys/uio.h>
#include <CTransport.h>

class CTransport
{
public:
    virtual  void    recv(void** ppData, size_t& size) = 0;
    virtual  void    send(iovec* parts, size_t numParts) = 0;
    virtual void end();
};
        

DESCRIPTION

Transports are objects that carry data across some high level protocol for data transport. Examples of high level protocols are ZeroMQ (ZMQ), MPI, or event raw TCP/IP sockets. Transports are normally bound into a CSender or CReceiver object.

Transport insulate the actual mechanisms of data transport from those objects. Each concrete transport must, at a minimum implement the recv and send methods. In addition, transports may implement the end method which is used to signal for a transport used inside a CSender that no more data will be transferred on that transport.

METHODS

virtual = 0 void recv(void** ppData, size_t& size);

Abstract interface to receive data from a concrete transport. ppData will be written with a pointer to the data received. The storage pointed to must have been dynamically allocated via the malloc()(3) library function.

size will be written with the number of bytes of data received. Note that all errors should be signalled via exceptions. While not mandatory, in many transports, a size of 0 is used to indicate end of data. In that case, the pointer is not meaningful and should not be freed.

virtual = 0 void send(iovec* parts, size_t numParts);

Writes a message to the peer of the transport. See the manual pages for writev(2) for a description of the iovec struct. numParts are the number of parts in the message

This call mechanism allows messages to be built via a gather mechanism that, in some transports, can minimize the data copies needed to marshall the complete message.

Concrete transports must gaurantee that they are done using parts buffers on return. Thus, if zero copy, asynchronous sends are use by the transport, the send must block until the send has actually completed.

virtual void end();

Transports that have a mechanism to signal an end of data should implement this. The default implementation is to do nothing. One standard used to indicate an end of data condition is to send a zero length message. The underlying transport protocol must, however support this if it is to be used.