NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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; -*- */
25 #ifndef NFD_DAEMON_FACE_UNIX_STREAM_CHANNEL_HPP
26 #define NFD_DAEMON_FACE_UNIX_STREAM_CHANNEL_HPP
27 
28 #include "channel.hpp"
29 
30 namespace nfd {
31 
32 namespace unix_stream {
33 typedef boost::asio::local::stream_protocol::endpoint Endpoint;
34 } // namespace unix_stream
35 
42 class UnixStreamChannel : public Channel
43 {
44 public:
48  struct Error : public std::runtime_error
49  {
50  Error(const std::string& what) : std::runtime_error(what) {}
51  };
52 
59  explicit
61 
63 
73  void
74  listen(const FaceCreatedCallback& onFaceCreated,
75  const ConnectFailedCallback& onAcceptFailed,
76  int backlog = boost::asio::local::stream_protocol::acceptor::max_connections);
77 
78  bool
79  isListening() const;
80 
81 private:
82  void
83  accept(const FaceCreatedCallback& onFaceCreated,
84  const ConnectFailedCallback& onAcceptFailed);
85 
86  void
87  handleAccept(const boost::system::error_code& error,
88  const FaceCreatedCallback& onFaceCreated,
89  const ConnectFailedCallback& onAcceptFailed);
90 
91 private:
92  unix_stream::Endpoint m_endpoint;
93  boost::asio::local::stream_protocol::acceptor m_acceptor;
94  boost::asio::local::stream_protocol::socket m_socket;
95 };
96 
97 inline bool
99 {
100  return m_acceptor.is_open();
101 }
102 
103 } // namespace nfd
104 
105 #endif // NFD_DAEMON_FACE_UNIX_STREAM_CHANNEL_HPP
UnixStreamChannel-related error.
STL namespace.
#define DECL_OVERRIDE
expands to 'override' if compiler supports this feature, otherwise expands to nothing ...
Definition: common.hpp:49
Error(const std::string &what)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
Class implementing a local channel to create faces.
function< void(const std::string &reason)> ConnectFailedCallback
Prototype for the callback that is called when face is failed to get created.
Definition: channel.hpp:46
boost::asio::local::stream_protocol::endpoint Endpoint
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback called when face is created (as a response to incoming connection or after...
Definition: channel.hpp:41