tcp-transport.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_TRANSPORT_TCP_TRANSPORT_HPP
23 #define NDN_TRANSPORT_TCP_TRANSPORT_HPP
24 
25 #include "transport.hpp"
26 #include "../util/config-file.hpp"
27 
28 namespace boost {
29 namespace asio {
30 namespace ip {
31 class tcp;
32 } // namespace ip
33 } // namespace asio
34 } // namespace boost
35 
36 namespace ndn {
37 
38 template<typename BaseTransport, typename Protocol>
39 class StreamTransportImpl;
40 
41 template<typename BaseTransport, typename Protocol>
42 class StreamTransportWithResolverImpl;
43 
46 class TcpTransport : public Transport
47 {
48 public:
49  explicit
50  TcpTransport(const std::string& host, const std::string& port = "6363");
51 
52  ~TcpTransport() override;
53 
54  void
55  connect(boost::asio::io_service& ioService,
56  const ReceiveCallback& receiveCallback) override;
57 
58  void
59  close() override;
60 
61  void
62  pause() override;
63 
64  void
65  resume() override;
66 
67  void
68  send(const Block& wire) override;
69 
70  void
71  send(const Block& header, const Block& payload) override;
72 
76  static shared_ptr<TcpTransport>
77  create(const std::string& uri);
78 
80  static std::pair<std::string, std::string>
81  getSocketHostAndPortFromUri(const std::string& uri);
82 
83 private:
84  std::string m_host;
85  std::string m_port;
86 
88  friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
89  friend class StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
90  shared_ptr<Impl> m_impl;
91 };
92 
93 } // namespace ndn
94 
95 #endif // NDN_TRANSPORT_TCP_TRANSPORT_HPP
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:74
void resume() override
resume the transport
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:98
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback) override
asynchronously open the connection
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
a transport using TCP socket
implementation detail of a Boost.Asio-based stream-oriented transport
void send(const Block &wire) override
send a TLV block through the transport
static shared_ptr< TcpTransport > create(const std::string &uri)
Create transport with parameters defined in URI.
implementation detail of a Boost.Asio-based stream-oriented transport with resolver support ...
provides TLV-block delivery service
Definition: transport.hpp:40
void close() override
Close the connection.
TcpTransport(const std::string &host, const std::string &port="6363")
void pause() override
pause the transport
function< void(const Block &wire)> ReceiveCallback
Definition: transport.hpp:52
~TcpTransport() override