unix-transport.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_TRANSPORT_UNIX_TRANSPORT_HPP
23 #define NDN_TRANSPORT_UNIX_TRANSPORT_HPP
24 
25 #include "transport.hpp"
26 #include "../util/config-file.hpp"
27 
28 namespace boost {
29 namespace asio {
30 namespace local {
31 class stream_protocol;
32 } // namespace local
33 } // namespace asio
34 } // namespace boost
35 
36 namespace ndn {
37 
38 template<typename BaseTransport, typename Protocol>
39 class StreamTransportImpl;
40 
43 class UnixTransport : public Transport
44 {
45 public:
46  explicit
47  UnixTransport(const std::string& unixSocket);
48 
49  ~UnixTransport() override;
50 
51  void
52  connect(boost::asio::io_service& ioService,
53  const ReceiveCallback& receiveCallback) override;
54 
55  void
56  close() override;
57 
58  void
59  pause() override;
60 
61  void
62  resume() override;
63 
64  void
65  send(const Block& wire) override;
66 
67  void
68  send(const Block& header, const Block& payload) override;
69 
73  static shared_ptr<UnixTransport>
74  create(const std::string& uri);
75 
77  static std::string
78  getSocketNameFromUri(const std::string& uri);
79 
80 private:
81  std::string m_unixSocket;
82 
84  friend class StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol>;
85  shared_ptr<Impl> m_impl;
86 };
87 
88 } // namespace ndn
89 
90 #endif // NDN_TRANSPORT_UNIX_TRANSPORT_HPP
a transport using Unix stream socket
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:74
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
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
void send(const Block &wire) override
send a TLV block through the transport
implementation detail of a Boost.Asio-based stream-oriented transport
static shared_ptr< UnixTransport > create(const std::string &uri)
Create transport with parameters defined in URI.
void pause() override
pause the transport
void resume() override
resume the transport
~UnixTransport() override
void close() override
Close the connection.
provides TLV-block delivery service
Definition: transport.hpp:40
void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback) override
asynchronously open the connection
UnixTransport(const std::string &unixSocket)
function< void(const Block &wire)> ReceiveCallback
Definition: transport.hpp:52