Class implementing TCP-based channel to create faces. More...
#include <tcp-channel.hpp>
Public Member Functions | |
TcpChannel (const tcp::Endpoint &localEndpoint, bool wantCongestionMarking, DetermineFaceScopeFromAddress determineFaceScope) | |
Create TCP channel for the local endpoint. More... | |
bool | isListening () const final |
Returns whether the channel is listening. More... | |
size_t | size () const final |
Returns the number of faces in the channel. More... | |
void | listen (const FaceCreatedCallback &onFaceCreated, const FaceCreationFailedCallback &onAcceptFailed, int backlog=boost::asio::ip::tcp::acceptor::max_connections) |
Enable listening on the local endpoint, accept connections, and create faces when remote host makes a connection. More... | |
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 . More... | |
Public Member Functions inherited from nfd::face::Channel | |
virtual | ~Channel () |
const FaceUri & | getUri () const |
size_t | getDefaultMtu () const |
Returns the default MTU for all faces created by this channel. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from nfd::face::Channel | |
void | setUri (const FaceUri &uri) |
void | setDefaultMtu (size_t mtu) |
Class implementing TCP-based channel to create faces.
Channel can create faces as a response to incoming TCP connections (TcpChannel::listen needs to be called for that to work) or explicitly after using TcpChannel::connect method.
Definition at line 49 of file tcp-channel.hpp.
nfd::face::TcpChannel::TcpChannel | ( | const tcp::Endpoint & | localEndpoint, |
bool | wantCongestionMarking, | ||
DetermineFaceScopeFromAddress | determineFaceScope | ||
) |
Create TCP channel for the local endpoint.
To enable creation faces upon incoming connections, one needs to explicitly call TcpChannel::listen method.
Definition at line 39 of file tcp-channel.cpp.
References NFD_LOG_CHAN_INFO, and nfd::face::Channel::setUri().
|
inlinefinalvirtual |
Returns whether the channel is listening.
Implements nfd::face::Channel.
Definition at line 62 of file tcp-channel.hpp.
Referenced by listen().
|
inlinefinalvirtual |
Returns the number of faces in the channel.
Implements nfd::face::Channel.
Definition at line 68 of file tcp-channel.hpp.
References websocketpp::extensions::permessage_deflate::mode::accept, websocketpp::transport::asio::socket::error::socket, and websocketpp::transport::error::timeout.
void nfd::face::TcpChannel::listen | ( | const FaceCreatedCallback & | onFaceCreated, |
const FaceCreationFailedCallback & | onAcceptFailed, | ||
int | backlog = boost::asio::ip::tcp::acceptor::max_connections |
||
) |
Enable listening on the local endpoint, accept connections, and create faces when remote host makes a connection.
onFaceCreated | Callback to notify successful creation of the face |
onAcceptFailed | Callback to notify when channel fails (accept call returns an error) |
backlog | The maximum length of the queue of pending incoming connections |
Definition at line 52 of file tcp-channel.cpp.
References websocketpp::extensions::permessage_deflate::mode::accept, isListening(), NFD_LOG_CHAN_DEBUG, and NFD_LOG_CHAN_WARN.
void nfd::face::TcpChannel::connect | ( | const tcp::Endpoint & | remoteEndpoint, |
const FaceParams & | params, | ||
const FaceCreatedCallback & | onFaceCreated, | ||
const FaceCreationFailedCallback & | onConnectFailed, | ||
time::nanoseconds | timeout = 8_s |
||
) |
Create a face by establishing a TCP connection to remoteEndpoint
.
Definition at line 74 of file tcp-channel.cpp.
References websocketpp::extensions::permessage_deflate::mode::accept, nfd::face::FaceParams::baseCongestionMarkingInterval, ndn::detail::CancelHandle::cancel(), nfd::face::connectFaceClosedSignal(), nfd::face::FaceParams::defaultCongestionThreshold, ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, nfd::getGlobalIoService(), nfd::getScheduler(), nonstd::optional_lite::std11::move(), NFD_LOG_CHAN_DEBUG, NFD_LOG_CHAN_TRACE, websocketpp::transport::error::operation_aborted, nfd::face::FaceParams::persistency, websocketpp::transport::asio::socket::error::socket, nfd::face::FaceParams::wantCongestionMarking, nfd::face::FaceParams::wantLocalFields, and nfd::face::FaceParams::wantLpReliability.