All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
tcp-transport-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_TCP_TRANSPORT_LITE_HPP
23 #define NDN_TCP_TRANSPORT_LITE_HPP
24 
25 #include "../../c/errors.h"
26 #include "../../c/transport/transport-types.h"
27 #include "../util/dynamic-uint8-array-lite.hpp"
28 #include "../encoding/element-listener-lite.hpp"
29 
30 namespace ndn {
31 
37 public:
49 
62  ndn_Error
63  isLocal(const char *host, bool& result);
64 
75  ndn_Error
76  connect(const char* host, unsigned short port, ElementListenerLite& elementListener);
77 
84  ndn_Error
85  send(const uint8_t* data, size_t dataLength);
86 
101  ndn_Error
102  processEvents(uint8_t *buffer, size_t bufferLength);
103 
108  ndn_Error
109  close();
110 
116  static TcpTransportLite&
117  downCast(ndn_TcpTransport& transport) { return *(TcpTransportLite*)&transport; }
118 
119  static const TcpTransportLite&
120  downCast(const ndn_TcpTransport& transport) { return *(TcpTransportLite*)&transport; }
121 };
122 
123 }
124 
125 #endif
An ElementListenerLite holds an OnReceivedElementLite function pointer.
Definition: element-listener-lite.hpp:37
TcpTransportLite(DynamicUInt8ArrayLite &buffer)
Create a TcpTransport with default values for no connection yet and to use the given DynamicUInt8Arra...
A DynamicUInt8ArrayLite holds a pointer to an allocated array, the length of the allocated array...
Definition: dynamic-uint8-array-lite.hpp:35
ndn_Error isLocal(const char *host, bool &result)
Determine whether this transport connecting to the host is to a node on the current machine; results ...
ndn_Error connect(const char *host, unsigned short port, ElementListenerLite &elementListener)
Connect with TCP to the host:port.
ndn_Error close()
Close the socket.
static TcpTransportLite & downCast(ndn_TcpTransport &transport)
Downcast the reference to the ndn_TcpTransport struct to a TcpTransportLite.
Definition: tcp-transport-lite.hpp:117
ndn_Error processEvents(uint8_t *buffer, size_t bufferLength)
Process any data to receive.
ndn_Error send(const uint8_t *data, size_t dataLength)
Send data to the socket.
Definition: transport-types.h:35
A TcpTransportLite object is used to send packets and to listen for incoming packets over a TCP socke...
Definition: tcp-transport-lite.hpp:36