blob: f0b5d0c93c06ba6eff3914f9dd45d7809471f300 [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
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07009#define NDN_TCPTRANSPORT_H
Jeff Thompson7850d782013-07-14 17:59:14 -070010
Jeff Thompson53412192013-08-06 13:35:50 -070011#include "socket-transport.h"
Jeff Thompson0d567da2013-07-14 22:10:21 -070012
Jeff Thompson2d27e2f2013-08-09 12:55:00 -070013#ifdef __cplusplus
Jeff Thompson7850d782013-07-14 17:59:14 -070014extern "C" {
15#endif
16
17struct ndn_TcpTransport {
Jeff Thompson0aa754a2013-07-17 17:42:28 -070018 struct ndn_SocketTransport base;
Jeff Thompson7850d782013-07-14 17:59:14 -070019};
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{
Jeff Thompson0aa754a2013-07-17 17:42:28 -070023 ndn_SocketTransport_init(&self->base);
Jeff Thompson7850d782013-07-14 17:59:14 -070024}
25
Jeff Thompson0aa754a2013-07-17 17:42:28 -070026static 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 Thompson0d567da2013-07-14 22:10:21 -070030
Jeff Thompson0aa754a2013-07-17 17:42:28 -070031static 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 Thompson0d567da2013-07-14 22:10:21 -070035
Jeff Thompson0aa754a2013-07-17 17:42:28 -070036static 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 Thompson0d567da2013-07-14 22:10:21 -070041
Jeff Thompson57963882013-08-05 16:01:25 -070042static inline ndn_Error ndn_TcpTransport_close(struct ndn_TcpTransport *self)
43{
44 return ndn_SocketTransport_close(&self->base);
45}
46
Jeff Thompson2d27e2f2013-08-09 12:55:00 -070047#ifdef __cplusplus
Jeff Thompson7850d782013-07-14 17:59:14 -070048}
49#endif
50
51#endif