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 |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame^] | 9 | #define NDN_TCPTRANSPORT_H |
Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 10 | |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 11 | #include "socket-transport.h" |
Jeff Thompson | 0d567da | 2013-07-14 22:10:21 -0700 | [diff] [blame] | 12 | |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame^] | 13 | #ifdef __cplusplus |
Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | struct ndn_TcpTransport { |
Jeff Thompson | 0aa754a | 2013-07-17 17:42:28 -0700 | [diff] [blame] | 18 | struct ndn_SocketTransport base; |
Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 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 | { |
Jeff Thompson | 0aa754a | 2013-07-17 17:42:28 -0700 | [diff] [blame] | 23 | ndn_SocketTransport_init(&self->base); |
Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Jeff Thompson | 0aa754a | 2013-07-17 17:42:28 -0700 | [diff] [blame] | 26 | static inline ndn_Error ndn_TcpTransport_connect(struct ndn_TcpTransport *self, char *host, unsigned short port) |
| 27 | { |
| 28 | return ndn_SocketTransport_connect(&self->base, SOCKET_TCP, host, port); |
| 29 | } |
Jeff Thompson | 0d567da | 2013-07-14 22:10:21 -0700 | [diff] [blame] | 30 | |
Jeff Thompson | 0aa754a | 2013-07-17 17:42:28 -0700 | [diff] [blame] | 31 | static inline ndn_Error ndn_TcpTransport_send(struct ndn_TcpTransport *self, unsigned char *data, unsigned int dataLength) |
| 32 | { |
| 33 | return ndn_SocketTransport_send(&self->base, data, dataLength); |
| 34 | } |
Jeff Thompson | 0d567da | 2013-07-14 22:10:21 -0700 | [diff] [blame] | 35 | |
Jeff Thompson | 0aa754a | 2013-07-17 17:42:28 -0700 | [diff] [blame] | 36 | static inline ndn_Error ndn_TcpTransport_receive |
| 37 | (struct ndn_TcpTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes) |
| 38 | { |
| 39 | return ndn_SocketTransport_receive(&self->base, buffer, bufferLength, nBytes); |
| 40 | } |
Jeff Thompson | 0d567da | 2013-07-14 22:10:21 -0700 | [diff] [blame] | 41 | |
Jeff Thompson | 5796388 | 2013-08-05 16:01:25 -0700 | [diff] [blame] | 42 | static inline ndn_Error ndn_TcpTransport_close(struct ndn_TcpTransport *self) |
| 43 | { |
| 44 | return ndn_SocketTransport_close(&self->base); |
| 45 | } |
| 46 | |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame^] | 47 | #ifdef __cplusplus |
Jeff Thompson | 7850d78 | 2013-07-14 17:59:14 -0700 | [diff] [blame] | 48 | } |
| 49 | #endif |
| 50 | |
| 51 | #endif |