blob: 19ed4e2db6b75d2df23ac2d1a536879a7b8a408a [file] [log] [blame]
Jeff Thompson7850d782013-07-14 17:59:14 -07001/*
2 * File: TcpTransport.h
3 * Author: jefft0
4 *
5 * Created on July 14, 2013, 4:15 PM
6 */
7
8#ifndef NDN_TCPTRANSPORT_H
9#define NDN_TCPTRANSPORT_H
10
Jeff Thompson0d567da2013-07-14 22:10:21 -070011#include "../errors.h"
12
Jeff Thompson7850d782013-07-14 17:59:14 -070013#ifdef __cplusplus
14extern "C" {
15#endif
16
17struct ndn_TcpTransport {
18 int socketDescriptor; /**< -1 if not connected */
19};
20
Jeff Thompson0d567da2013-07-14 22:10:21 -070021static inline void ndn_TcpTransport_init(struct ndn_TcpTransport *self)
Jeff Thompson7850d782013-07-14 17:59:14 -070022{
23 self->socketDescriptor = -1;
24}
25
Jeff Thompson0d567da2013-07-14 22:10:21 -070026ndn_Error ndn_TcpTransport_connect(struct ndn_TcpTransport *self, char *host, unsigned short port);
27
28ndn_Error ndn_TcpTransport_send(struct ndn_TcpTransport *self, unsigned char *data, unsigned int dataLength);
29
30ndn_Error ndn_TcpTransport_receive
31 (struct ndn_TcpTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes);
32
Jeff Thompson7850d782013-07-14 17:59:14 -070033int testTcpTransport(unsigned char *data, unsigned int dataLength);
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif