Added initial TcpTransport
diff --git a/ndn-cpp/c/network/TcpTransport.c b/ndn-cpp/c/network/TcpTransport.c
new file mode 100644
index 0000000..30e6828
--- /dev/null
+++ b/ndn-cpp/c/network/TcpTransport.c
@@ -0,0 +1,89 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "TcpTransport.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+#include <arpa/inet.h>
+
+// get sockaddr, IPv4 or IPv6:
+static inline void *get_in_addr(struct sockaddr *sa)
+{
+ if (sa->sa_family == AF_INET)
+ return &(((struct sockaddr_in*)sa)->sin_addr);
+
+ return &(((struct sockaddr_in6*)sa)->sin6_addr);
+}
+
+ndn_Error ndn_TcpTransport_connect(ndn_TcpTransport *self, char *host, int port)
+{
+
+}
+
+int testTcpTransport(unsigned char *data, unsigned int dataLength)
+{
+ struct addrinfo hints, *serverInfo;
+
+ printf("starting\n");
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+
+ if (getaddrinfo("E.hub.ndn.ucla.edu", "9695", &hints, &serverInfo) != 0)
+ return 1;
+
+ // loop through all the results and connect to the first we can
+ struct addrinfo *p;
+ for(p = serverInfo; p != NULL; p = p->ai_next) {
+ if ((socketDescriptor = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
+ continue;
+
+ if (connect(socketDescriptor, p->ai_addr, p->ai_addrlen) == -1) {
+ close(socketDescriptor);
+ continue;
+ }
+
+ break;
+ }
+
+ if (p == NULL)
+ return 2;
+
+ freeaddrinfo(serverInfo); // all done with this structure
+
+ int nBytes;
+ while (1) {
+ if ((nBytes = send(socketDescriptor, data, dataLength, 0)) < 0)
+ return 1;
+ if (nBytes >= dataLength)
+ break;
+
+ dataLength -= nBytes;
+ }
+
+ unsigned char buffer[1000];
+ if ((nBytes = recv(socketDescriptor, buffer, sizeof(buffer) - 1, 0)) == -1)
+ return 1;
+
+ printf("received %d bytes\n", nBytes);
+ int i;
+ for (i = 0; i < nBytes; ++i)
+ printf("%02X ", (unsigned int)buffer[i]);
+ printf("\n");
+
+ close(socketDescriptor);
+
+ return 0;
+}
diff --git a/ndn-cpp/c/network/TcpTransport.h b/ndn-cpp/c/network/TcpTransport.h
new file mode 100644
index 0000000..82ef03b
--- /dev/null
+++ b/ndn-cpp/c/network/TcpTransport.h
@@ -0,0 +1,30 @@
+/*
+ * File: TcpTransport.h
+ * Author: jefft0
+ *
+ * Created on July 14, 2013, 4:15 PM
+ */
+
+#ifndef NDN_TCPTRANSPORT_H
+#define NDN_TCPTRANSPORT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ndn_TcpTransport {
+ int socketDescriptor; /**< -1 if not connected */
+};
+
+static inline void ndn_TcpTransport_init(ndn_TcpTransport *self)
+{
+ self->socketDescriptor = -1;
+}
+
+int testTcpTransport(unsigned char *data, unsigned int dataLength);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif