blob: a5e89f7528a0de75a75969017b7f82ad11252f26 [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
37#ifdef __cplusplus
38}
39#endif
40
41#endif