blob: db90ae47bbb1993f0a3eb927e21ca7f354bad9e3 [file] [log] [blame]
Alexander Afanasyev20d2c582014-01-26 15:32:51 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyev5964fb72014-02-18 12:42:45 -08003 * Copyright (C) 2013-2014 Regents of the University of California.
Alexander Afanasyev20d2c582014-01-26 15:32:51 -08004 * See COPYING for copyright and distribution information.
5 */
6
Alexander Afanasyev5964fb72014-02-18 12:42:45 -08007#ifndef NDN_TRANSPORT_TCP_TRANSPORT_HPP
8#define NDN_TRANSPORT_TCP_TRANSPORT_HPP
Alexander Afanasyev20d2c582014-01-26 15:32:51 -08009
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080010#include "../common.hpp"
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080011#include "transport.hpp"
12
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080013// forward declaration
14namespace boost { namespace asio { namespace ip { class tcp; } } }
15
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080016namespace ndn {
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080017
18// forward declaration
19template<class T, class U> class StreamTransportImpl;
20template<class T, class U> class StreamTransportWithResolverImpl;
21
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080022class TcpTransport : public Transport
23{
24public:
25 TcpTransport(const std::string& host, const std::string& port = "6363");
26 ~TcpTransport();
27
28 // from Transport
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070029 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080030 connect(boost::asio::io_service& ioService,
31 const ReceiveCallback& receiveCallback);
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070032
33 virtual void
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080034 close();
35
Alexander Afanasyev52afb3f2014-03-07 09:05:35 +000036 virtual void
37 pause();
38
39 virtual void
40 resume();
41
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070042 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080043 send(const Block& wire);
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080044
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070045 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080046 send(const Block& header, const Block& payload);
47
48private:
49 std::string m_host;
50 std::string m_port;
51
52 typedef StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp> Impl;
53 friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
54 friend class StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
55 shared_ptr< Impl > m_impl;
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080056};
57
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080058} // namespace ndn
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080059
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080060#endif // NDN_TRANSPORT_TCP_TRANSPORT_HPP