26 #ifndef NFD_DAEMON_FACE_TCP_CHANNEL_HPP
27 #define NFD_DAEMON_FACE_TCP_CHANNEL_HPP
31 #include <ndn-cxx/util/scheduler.hpp>
33 #include <boost/asio/ip/tcp.hpp>
38 using Endpoint = boost::asio::ip::tcp::endpoint;
44 const boost::asio::ip::address& remote)>;
67 return m_acceptor.is_open();
73 return m_channelFaces.size();
88 int backlog = boost::asio::socket_base::max_listen_connections);
98 time::nanoseconds timeout = 8_s);
102 createFace(boost::asio::ip::tcp::socket&& socket,
112 handleConnect(
const boost::system::error_code& error,
114 const shared_ptr<boost::asio::ip::tcp::socket>& socket,
116 const ndn::scheduler::EventId& connectTimeoutEvent,
122 const shared_ptr<boost::asio::ip::tcp::socket>& socket,
127 const bool m_wantCongestionMarking;
128 boost::asio::ip::tcp::acceptor m_acceptor;
129 std::map<tcp::Endpoint, shared_ptr<Face>> m_channelFaces;
Represents a channel that listens on a local endpoint.
Class implementing a TCP-based channel to create faces.
size_t size() const final
Returns the number of faces in the channel.
TcpChannel(const tcp::Endpoint &localEndpoint, bool wantCongestionMarking, DetermineFaceScopeFromAddress determineFaceScope)
Create a TCP channel for the specified localEndpoint.
void listen(const FaceCreatedCallback &onFaceCreated, const FaceCreationFailedCallback &onAcceptFailed, int backlog=boost::asio::socket_base::max_listen_connections)
Enable listening on the local endpoint, accept connections, and create faces when remote host makes a...
void connect(const tcp::Endpoint &remoteEndpoint, const FaceParams ¶ms, const FaceCreatedCallback &onFaceCreated, const FaceCreationFailedCallback &onConnectFailed, time::nanoseconds timeout=8_s)
Create a face by establishing a TCP connection to remoteEndpoint.
bool isListening() const final
Returns whether the channel is listening.
std::function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when a face fails to be created.
std::function< ndn::nfd::FaceScope(const boost::asio::ip::address &local, const boost::asio::ip::address &remote)> DetermineFaceScopeFromAddress
std::function< void(const shared_ptr< Face > &)> FaceCreatedCallback
Prototype for the callback that is invoked when a face is created (in response to an incoming connect...
boost::asio::ip::tcp::endpoint Endpoint
Parameters used to set Transport properties or LinkService options on a newly created face.