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 | |
| 36 | virtual void |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 37 | send(const Block& wire); |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 38 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 39 | virtual void |
| 40 | send(const Block& header, const Block& payload); |
| 41 | |
| 42 | private: |
| 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 Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 52 | } // namespace ndn |
Alexander Afanasyev | 20d2c58 | 2014-01-26 15:32:51 -0800 | [diff] [blame] | 53 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 54 | #endif // NDN_TRANSPORT_TCP_TRANSPORT_HPP |