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 
33 public:
45 
58  ndn_Error
59  isLocal(const char *host, bool& result);
60 
71  ndn_Error
72  connect(const char* host, unsigned short port, ElementListenerLite& elementListener);
73 
80  ndn_Error
81  send(const uint8_t* data, size_t dataLength);
82 
97  ndn_Error
98  processEvents(uint8_t *buffer, size_t bufferLength);
99 
104  ndn_Error
105  close();
106 
112  static TcpTransportLite&
113  downCast(ndn_TcpTransport& transport) { return *(TcpTransportLite*)&transport; }
114 
115  static const TcpTransportLite&
116  downCast(const ndn_TcpTransport& transport) { return *(TcpTransportLite*)&transport; }
117 };
118 
119 }
120 
121 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
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:113
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
Definition: tcp-transport-lite.hpp:32