blob: 6973d19d59bfca66ba7d5725ead7f33af2ba05c5 [file] [log] [blame]
Jeff Thompson0aa754a2013-07-17 17:42:28 -07001/**
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
13extern "C" {
14#endif
15
16typedef enum {
17 SOCKET_TCP,
18 SOCKET_UDP
19} ndn_SocketType;
20
21struct ndn_SocketTransport {
22 int socketDescriptor; /**< -1 if not connected */
23};
24
25static inline void ndn_SocketTransport_init(struct ndn_SocketTransport *self)
26{
27 self->socketDescriptor = -1;
28}
29
30ndn_Error ndn_SocketTransport_connect(struct ndn_SocketTransport *self, ndn_SocketType socketType, char *host, unsigned short port);
31
32ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, unsigned char *data, unsigned int dataLength);
33
34ndn_Error ndn_SocketTransport_receive
35 (struct ndn_SocketTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes);
36
Jeff Thompson57963882013-08-05 16:01:25 -070037ndn_Error ndn_SocketTransport_close(struct ndn_SocketTransport *self);
38
Jeff Thompson0aa754a2013-07-17 17:42:28 -070039#ifdef __cplusplus
40}
41#endif
42
43#endif