blob: b97e2a10cd6e1afb6ddb86adacaa9bc752d04627 [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
36 virtual void
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080037 send(const Block& wire);
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080038
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080039 virtual void
40 send(const Block& header, const Block& payload);
41
42private:
43 std::string m_host;
44 std::string m_port;
45
46 typedef StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp> Impl;
47 friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
48 friend class StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
49 shared_ptr< Impl > m_impl;
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080050};
51
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080052} // namespace ndn
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080053
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080054#endif // NDN_TRANSPORT_TCP_TRANSPORT_HPP