#include <CReceiver> class CReceiver { public: CReceiver(CTransport& rTransport); void getMessage(void** ppData, size_t& size); CTransport* setTransport(CTransport& rTransport); };
This class uses a transport to receive data from
a CSender
. Any complex
communication pattern normally is a collaboration
implemented by the transports of the
CSender
and
CReceiver
objects.
CReceiver(CTransport& rTransport);
Constructs the receiver by binding a transport that will be used for message passing. Note that the receiver object will appear to the user code like a unidirectional pipe of messages that transfer data into the application code that uses it.
void getMessage(void** ppData, , size_t& size);
Gets the next message from the peer.
ppData
points to
storage for a pointer. The pointer will
be filled in with a pointer to the data
received. The data is dynamically
allocated via
malloc
(3) and must
be released via a call to the
free
(3) function.
size
is a reference
that will be filled in with the actual number
of bytes in the message received.
CTransport* setTransport(CTransport& rTransport);
Allows a receiver to dyamically set the
transport it uses (to
rTransport
.
A pointer to the previous transport is
returned to the caller.
If you find yourself using this you should probably reconsider the design of your application's communication scheme.