blob: 7418b183f3231b72288eb6ea31bb4bad2fd27d81 [file] [log] [blame]
Alexander Afanasyev20d2c582014-01-26 15:32:51 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080011 */
12
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080013#ifndef NDN_TRANSPORT_TCP_TRANSPORT_HPP
14#define NDN_TRANSPORT_TCP_TRANSPORT_HPP
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080015
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080016#include "../common.hpp"
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080017#include "transport.hpp"
18
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080019// forward declaration
20namespace boost { namespace asio { namespace ip { class tcp; } } }
21
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080022namespace ndn {
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080023
24// forward declaration
25template<class T, class U> class StreamTransportImpl;
26template<class T, class U> class StreamTransportWithResolverImpl;
27
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080028class TcpTransport : public Transport
29{
30public:
31 TcpTransport(const std::string& host, const std::string& port = "6363");
32 ~TcpTransport();
33
34 // from Transport
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070035 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080036 connect(boost::asio::io_service& ioService,
37 const ReceiveCallback& receiveCallback);
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070038
39 virtual void
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080040 close();
41
Alexander Afanasyev52afb3f2014-03-07 09:05:35 +000042 virtual void
43 pause();
44
45 virtual void
46 resume();
47
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070048 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080049 send(const Block& wire);
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080050
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070051 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080052 send(const Block& header, const Block& payload);
53
54private:
55 std::string m_host;
56 std::string m_port;
57
58 typedef StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp> Impl;
59 friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
60 friend class StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
61 shared_ptr< Impl > m_impl;
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080062};
63
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080064} // namespace ndn
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080065
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080066#endif // NDN_TRANSPORT_TCP_TRANSPORT_HPP