Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 3 | * Copyright (C) 2013-2014 Regents of the University of California. |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 7 | #ifndef NDN_TRANSPORT_TCP_TRANSPORT_HPP |
| 8 | #define NDN_TRANSPORT_TCP_TRANSPORT_HPP |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 9 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 10 | #include "../common.hpp" |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 11 | #include "transport.hpp" |
| 12 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 13 | // forward declaration |
| 14 | namespace boost { namespace asio { namespace ip { class tcp; } } } |
| 15 | |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 16 | namespace ndn { |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 17 | |
| 18 | // forward declaration |
| 19 | template<class T, class U> class StreamTransportImpl; |
| 20 | template<class T, class U> class StreamTransportWithResolverImpl; |
| 21 | |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 22 | class TcpTransport : public Transport |
| 23 | { |
| 24 | public: |
| 25 | TcpTransport(const std::string& host, const std::string& port = "6363"); |
| 26 | ~TcpTransport(); |
| 27 | |
| 28 | // from Transport |
| 29 | virtual void |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 30 | connect(boost::asio::io_service& ioService, |
| 31 | const ReceiveCallback& receiveCallback); |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 32 | |
| 33 | virtual void |
| 34 | close(); |
| 35 | |
Alexander Afanasyev | 52afb3f | 2014-03-07 09:05:35 +0000 | [diff] [blame] | 36 | virtual void |
| 37 | pause(); |
| 38 | |
| 39 | virtual void |
| 40 | resume(); |
| 41 | |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 42 | virtual void |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 43 | send(const Block& wire); |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 44 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 45 | virtual void |
| 46 | send(const Block& header, const Block& payload); |
| 47 | |
| 48 | private: |
| 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 Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 56 | }; |
| 57 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 58 | } // namespace ndn |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 59 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 60 | #endif // NDN_TRANSPORT_TCP_TRANSPORT_HPP |