socket-transport.h
1 
21 #ifndef NDN_SOCKETTRANSPORT_H
22 #define NDN_SOCKETTRANSPORT_H
23 
24 #include <ndn-cpp/c/common.h>
25 #include <ndn-cpp/c/errors.h>
26 #include <ndn-cpp/c/transport/transport-types.h>
27 #include "../encoding/element-reader.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 typedef enum {
34  SOCKET_TCP,
35  SOCKET_UDP,
36  SOCKET_UNIX
37 } ndn_SocketType;
38 
50 static __inline void ndn_SocketTransport_initialize
51  (struct ndn_SocketTransport *self, struct ndn_DynamicUInt8Array *buffer)
52 {
53  self->socketDescriptor = -1;
54  ndn_ElementReader_initialize(&self->elementReader, 0, buffer);
55 }
56 
70 ndn_Error ndn_SocketTransport_connect
71  (struct ndn_SocketTransport *self, ndn_SocketType socketType, const char *host,
72  unsigned short port, struct ndn_ElementListener *elementListener);
73 
81 ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, const uint8_t *data, size_t dataLength);
82 
90 ndn_Error ndn_SocketTransport_receiveIsReady(struct ndn_SocketTransport *self, int *receiveIsReady);
91 
101 ndn_Error ndn_SocketTransport_receive
102  (struct ndn_SocketTransport *self, uint8_t *buffer, size_t bufferLength, size_t *nBytes);
103 
119 ndn_Error
120 ndn_SocketTransport_processEvents
121  (struct ndn_SocketTransport *self, uint8_t *buffer, size_t bufferLength);
122 
128 ndn_Error ndn_SocketTransport_close(struct ndn_SocketTransport *self);
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif
Copyright (C) 2015-2016 Regents of the University of California.
Definition: transport-types.h:30
An ndn_ElementListener struct holds a function pointer onReceivedElement.
Definition: element-reader-types.h:37
A struct ndn_DynamicUInt8Array holds a pointer to an allocated array, the length of the allocated arr...
Definition: dynamic-uint8-array-types.h:40