NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
unix-stream-channel.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_FACE_UNIX_STREAM_CHANNEL_HPP
27 #define NFD_DAEMON_FACE_UNIX_STREAM_CHANNEL_HPP
28 
29 #include "channel.hpp"
30 
31 namespace nfd {
32 
33 namespace unix_stream {
34 typedef boost::asio::local::stream_protocol::endpoint Endpoint;
35 } // namespace unix_stream
36 
43 class UnixStreamChannel : public Channel
44 {
45 public:
49  struct Error : public std::runtime_error
50  {
51  Error(const std::string& what) : std::runtime_error(what) {}
52  };
53 
60  explicit
62 
63  ~UnixStreamChannel() override;
64 
74  void
75  listen(const FaceCreatedCallback& onFaceCreated,
76  const FaceCreationFailedCallback& onAcceptFailed,
77  int backlog = boost::asio::local::stream_protocol::acceptor::max_connections);
78 
79  bool
80  isListening() const;
81 
82 private:
83  void
84  accept(const FaceCreatedCallback& onFaceCreated,
85  const FaceCreationFailedCallback& onAcceptFailed);
86 
87  void
88  handleAccept(const boost::system::error_code& error,
89  const FaceCreatedCallback& onFaceCreated,
90  const FaceCreationFailedCallback& onAcceptFailed);
91 
92 private:
93  unix_stream::Endpoint m_endpoint;
94  boost::asio::local::stream_protocol::acceptor m_acceptor;
95  boost::asio::local::stream_protocol::socket m_socket;
96 };
97 
98 inline bool
100 {
101  return m_acceptor.is_open();
102 }
103 
104 } // namespace nfd
105 
106 #endif // NFD_DAEMON_FACE_UNIX_STREAM_CHANNEL_HPP
UnixStreamChannel-related error.
STL namespace.
Error(const std::string &what)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
Class implementing a local channel to create faces.
function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when the face fails to be created.
Definition: channel.hpp:44
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback that is invoked when the face is created (as a response to incoming connec...
Definition: channel.hpp:38
boost::asio::local::stream_protocol::endpoint Endpoint