Jeff Thompson | 0aa754a | 2013-07-17 17:42:28 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NDN_SOCKETTRANSPORT_H |
| 7 | #define NDN_SOCKETTRANSPORT_H |
| 8 | |
| 9 | #include <sys/socket.h> |
| 10 | #include "../errors.h" |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | typedef enum { |
| 17 | SOCKET_TCP, |
| 18 | SOCKET_UDP |
| 19 | } ndn_SocketType; |
| 20 | |
| 21 | struct ndn_SocketTransport { |
| 22 | int socketDescriptor; /**< -1 if not connected */ |
| 23 | }; |
| 24 | |
| 25 | static inline void ndn_SocketTransport_init(struct ndn_SocketTransport *self) |
| 26 | { |
| 27 | self->socketDescriptor = -1; |
| 28 | } |
| 29 | |
| 30 | ndn_Error ndn_SocketTransport_connect(struct ndn_SocketTransport *self, ndn_SocketType socketType, char *host, unsigned short port); |
| 31 | |
| 32 | ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, unsigned char *data, unsigned int dataLength); |
| 33 | |
| 34 | ndn_Error ndn_SocketTransport_receive |
| 35 | (struct ndn_SocketTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes); |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | } |
| 39 | #endif |
| 40 | |
| 41 | #endif |