Public Member Functions | Static Public Member Functions | List of all members
ndn::UnixTransportLite Class Reference
Inheritance diagram for ndn::UnixTransportLite:
ndn_UnixTransport

Public Member Functions

 UnixTransportLite (DynamicUInt8ArrayLite &buffer)
 Create a UnixTransport with default values for no connection yet and to use the given DynamicUInt8ArrayLite buffer for the ElementReader. More...
 
ndn_Error connect (char *filePath, ElementListenerLite &elementListener)
 Connect with a Unix Socket to the socket filePath. More...
 
ndn_Error send (const uint8_t *data, size_t dataLength)
 Send data to the socket. More...
 
ndn_Error processEvents (uint8_t *buffer, size_t bufferLength)
 Process any data to receive. More...
 
ndn_Error close ()
 Close the socket. More...
 

Static Public Member Functions

static bool isLocal ()
 Determine whether this transport is to a node on the current machine. More...
 
static UnixTransportLitedownCast (ndn_UnixTransport &transport)
 Downcast the reference to the ndn_UnixTransport struct to a UnixTransportLite. More...
 
static const UnixTransportLitedownCast (const ndn_UnixTransport &transport)
 

Constructor & Destructor Documentation

ndn::UnixTransportLite::UnixTransportLite ( DynamicUInt8ArrayLite buffer)

Create a UnixTransport with default values for no connection yet and to use the given DynamicUInt8ArrayLite buffer for the ElementReader.

Note that the ElementReader is not valid until you call connect.

Parameters
bufferA DynamicUInt8ArrayLite which is used to save data before calling the elementListener (see connect). The object must remain valid during the entire life of this object. If the reallocFunction given to buffer's constructor is 0, then its array must be large enough to save a full element, perhaps MAX_NDN_PACKET_SIZE bytes.

Member Function Documentation

ndn_Error ndn::UnixTransportLite::close ( )

Close the socket.

Returns
0 for success, else an error code.
ndn_Error ndn::UnixTransportLite::connect ( char *  filePath,
ElementListenerLite elementListener 
)

Connect with a Unix Socket to the socket filePath.

Parameters
filePathThe file path of the Unix socket to connect to.
elementListenerThe ElementListenerLite whose onReceivedElement callback is called by processEvents. The elementListener must remain valid during the life of this object or until replaced by the next call to connect.
Returns
0 for success, else an error code.
static UnixTransportLite& ndn::UnixTransportLite::downCast ( ndn_UnixTransport transport)
inlinestatic

Downcast the reference to the ndn_UnixTransport struct to a UnixTransportLite.

Parameters
transportA reference to the ndn_UnixTransport struct.
Returns
The same reference as UnixTransportLite.
static bool ndn::UnixTransportLite::isLocal ( )
static

Determine whether this transport is to a node on the current machine.

Unix transports are always local.

Returns
True because Unix transports are always local.
ndn_Error ndn::UnixTransportLite::processEvents ( uint8_t *  buffer,
size_t  bufferLength 
)

Process any data to receive.

For each element received, call (*elementListener->onReceivedElement)(element, elementLength) for the elementListener in the elementReader given to connect(). This is non-blocking and will return immediately if there is no data to receive.

Parameters
bufferA pointer to a buffer for receiving data. Note that this is only for temporary use and is not the way that this function supplies data. It supplies the data by calling the onReceivedElement callback.
bufferLengthThe size of buffer. The buffer should be as large as resources permit up to MAX_NDN_PACKET_SIZE, but smaller sizes will work however may be less efficient due to multiple calls to socket receive and more processing by the ElementReader.
Returns
0 for success, else an error code.
ndn_Error ndn::UnixTransportLite::send ( const uint8_t *  data,
size_t  dataLength 
)

Send data to the socket.

Parameters
dataA pointer to the buffer of data to send.
dataLengthThe number of bytes in data.
Returns
0 for success, else an error code.

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