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
-
buffer | A 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. |
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
-
filePath | The file path of the Unix socket to connect to. |
elementListener | The 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 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
-
buffer | A 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. |
bufferLength | The 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
-
data | A pointer to the buffer of data to send. |
dataLength | The number of bytes in data. |
- Returns
- 0 for success, else an error code.
The documentation for this class was generated from the following file: