Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 1 | /* |
| 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 Thompson | 0d567da | 2013-07-14 22:10:21 -0700 | [diff] [blame^] | 11 | #include "../errors.h" |
| 12 | |
Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | struct ndn_TcpTransport { |
| 18 | int socketDescriptor; /**< -1 if not connected */ |
| 19 | }; |
| 20 | |
Jeff Thompson | 0d567da | 2013-07-14 22:10:21 -0700 | [diff] [blame^] | 21 | static inline void ndn_TcpTransport_init(struct ndn_TcpTransport *self) |
Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 22 | { |
| 23 | self->socketDescriptor = -1; |
| 24 | } |
| 25 | |
Jeff Thompson | 0d567da | 2013-07-14 22:10:21 -0700 | [diff] [blame^] | 26 | ndn_Error ndn_TcpTransport_connect(struct ndn_TcpTransport *self, char *host, unsigned short port); |
| 27 | |
| 28 | ndn_Error ndn_TcpTransport_send(struct ndn_TcpTransport *self, unsigned char *data, unsigned int dataLength); |
| 29 | |
| 30 | ndn_Error ndn_TcpTransport_receive |
| 31 | (struct ndn_TcpTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes); |
| 32 | |
Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 33 | int testTcpTransport(unsigned char *data, unsigned int dataLength); |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | } |
| 37 | #endif |
| 38 | |
| 39 | #endif |