Create a TcpTransport 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::TcpTransportLite::close |
( |
| ) |
|
Close the socket.
- Returns
- 0 for success, else an error code.
ndn_Error ndn::TcpTransportLite::connect |
( |
const char * |
host, |
|
|
unsigned short |
port, |
|
|
ElementListenerLite & |
elementListener |
|
) |
| |
Connect with TCP to the host:port.
- Parameters
-
host | The host to connect to. |
port | The port 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.
ndn_Error ndn::TcpTransportLite::isLocal |
( |
const char * |
host, |
|
|
bool & |
result |
|
) |
| |
Determine whether this transport connecting to the host is to a node on the current machine; results are not cached.
According to http://redmine.named-data.net/projects/nfd/wiki/ScopeControl#local-face, TCP transports with a loopback address are local. If host is a host name, this will do a blocking DNS lookup; otherwise this will parse the IP address and examine the first octet to determine if it is a loopback address (e.g. the first IPv4 octet is 127 or IPv6 is "::1").
- Parameters
-
host | The host to check. |
result | Set result to true if the host is local, false if not. |
- Returns
- 0 for success, else an error code.
ndn_Error ndn::TcpTransportLite::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::TcpTransportLite::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: