blob: 6795580176ca9011d38a611635703f4e2e72b547 [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
29 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080030 connect(boost::asio::io_service& ioService,
31 const ReceiveCallback& receiveCallback);
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080032
33 virtual void
34 close();
35
Alexander Afanasyev52afb3f2014-03-07 09:05:35 +000036 virtual void
37 pause();
38
39 virtual void
40 resume();
41
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080042 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080043 send(const Block& wire);
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080044
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080045 virtual void
46 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