All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tcp-transport.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
7 #ifndef NDN_TRANSPORT_TCP_TRANSPORT_HPP
8 #define NDN_TRANSPORT_TCP_TRANSPORT_HPP
9 
10 #include "../common.hpp"
11 #include "transport.hpp"
12 
13 // forward declaration
14 namespace boost { namespace asio { namespace ip { class tcp; } } }
15 
16 namespace ndn {
17 
18 // forward declaration
19 template<class T, class U> class StreamTransportImpl;
20 template<class T, class U> class StreamTransportWithResolverImpl;
21 
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
30  connect(boost::asio::io_service& ioService,
31  const ReceiveCallback& receiveCallback);
32 
33  virtual void
34  close();
35 
36  virtual void
37  pause();
38 
39  virtual void
40  resume();
41 
42  virtual void
43  send(const Block& wire);
44 
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 
53  friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
54  friend class StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
55  shared_ptr< Impl > m_impl;
56 };
57 
58 } // namespace ndn
59 
60 #endif // NDN_TRANSPORT_TCP_TRANSPORT_HPP
ptr_lib::function< void(const Block &wire)> ReceiveCallback
Definition: transport.hpp:25
virtual void resume()
virtual void pause()
Class representing wire element of the NDN packet.
Definition: block.hpp:26
virtual void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback)
Connect transport.
virtual void send(const Block &wire)
Set data to the host.
virtual void close()
Close the connection.
TcpTransport(const std::string &host, const std::string &port="6363")