transport: Implementing TcpTransport
Refs #1156 (http://redmine.named-data.net/issues/1156)
Change-Id: I03322acabc558e7ef220b9da07ce72095e9d8039
diff --git a/include/ndn-cpp-dev/face.hpp b/include/ndn-cpp-dev/face.hpp
index ec4fe27..61d872f 100644
--- a/include/ndn-cpp-dev/face.hpp
+++ b/include/ndn-cpp-dev/face.hpp
@@ -11,6 +11,7 @@
#include "node.hpp"
#include "transport/transport.hpp"
#include "transport/unix-transport.hpp"
+#include "transport/tcp-transport.hpp"
namespace ndn {
@@ -58,13 +59,13 @@
/**
* Create a new Face for communication with an NDN hub at host:port using the default TcpTransport.
* @param host The host of the NDN hub.
- * @param port The port of the NDN hub. If omitted. use 6363.
+ * @param port The port or service name of the NDN hub. If omitted. use 6363.
*/
- // Face(const char *host, unsigned short port = 6363)
- // : node_(ptr_lib::shared_ptr<TcpTransport>(new TcpTransport(host, port)))
- // {
- // }
-
+ Face(const std::string &host, const std::string &port = "6363")
+ : node_(ptr_lib::shared_ptr<TcpTransport>(new TcpTransport(host, port)))
+ {
+ }
+
/**
* Send the Interest through the transport, read the entire response and call onData(interest, data).
* @param interest A reference to the Interest. This copies the Interest.
diff --git a/include/ndn-cpp-dev/transport/tcp-transport.hpp b/include/ndn-cpp-dev/transport/tcp-transport.hpp
new file mode 100644
index 0000000..00f3fef
--- /dev/null
+++ b/include/ndn-cpp-dev/transport/tcp-transport.hpp
@@ -0,0 +1,43 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_TCP_TRANSPORT_HPP
+#define NDN_TCP_TRANSPORT_HPP
+
+#include <string>
+#include "transport.hpp"
+
+namespace ndn {
+
+class TcpTransport : public Transport
+{
+public:
+ TcpTransport(const std::string& host, const std::string& port = "6363");
+ ~TcpTransport();
+
+ // from Transport
+ virtual void
+ connect(boost::asio::io_service &ioService,
+ const ReceiveCallback &receiveCallback);
+
+ virtual void
+ close();
+
+ virtual void
+ send(const Block &wire);
+
+private:
+ std::string host_;
+ std::string port_;
+
+ class Impl;
+ ptr_lib::shared_ptr<Impl> impl_;
+};
+
+}
+
+#endif // NDN_TCP_TRANSPORT_HPP