Class implementing UDP-based channel to create faces. More...
#include <udp-channel.hpp>
Public Member Functions | |
UdpChannel (const udp::Endpoint &localEndpoint, const time::seconds &timeout) | |
Create UDP channel for the local endpoint. More... | |
void | listen (const FaceCreatedCallback &onFaceCreated, const ConnectFailedCallback &onReceiveFailed) |
Enable listening on the local endpoint, accept connections, and create faces when remote host makes a connection. More... | |
void | connect (const udp::Endpoint &remoteEndpoint, ndn::nfd::FacePersistency persistency, const FaceCreatedCallback &onFaceCreated, const ConnectFailedCallback &onConnectFailed) |
Create a face by establishing connection to remote endpoint. More... | |
size_t | size () const |
Get number of faces in the channel. More... | |
bool | isListening () const |
Public Member Functions inherited from nfd::Channel | |
virtual | ~Channel () |
const FaceUri & | getUri () const |
Additional Inherited Members | |
Public Types inherited from nfd::Channel | |
typedef 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 connection is established) More... | |
typedef function< void(const std::string &reason)> | ConnectFailedCallback |
Prototype for the callback that is called when face is failed to get created. More... | |
Protected Member Functions inherited from nfd::Channel | |
void | setUri (const FaceUri &uri) |
Class implementing UDP-based channel to create faces.
Definition at line 42 of file udp-channel.hpp.
nfd::UdpChannel::UdpChannel | ( | const udp::Endpoint & | localEndpoint, |
const time::seconds & | timeout | ||
) |
Create UDP channel for the local endpoint.
To enable creation of faces upon incoming connections, one needs to explicitly call UdpChannel::listen method. The created socket is bound to the localEndpoint. reuse_address option is set
UdpChannel::Error | if bind on the socket fails |
Definition at line 36 of file udp-channel.cpp.
References nfd::Channel::setUri().
void nfd::UdpChannel::listen | ( | const FaceCreatedCallback & | onFaceCreated, |
const ConnectFailedCallback & | onReceiveFailed | ||
) |
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 |
Once a face is created, if it doesn't send/receive anything for a period of time equal to timeout, it will be destroyed
UdpChannel::Error | if called multiple times |
Definition at line 46 of file udp-channel.cpp.
References isListening(), ndn::MAX_NDN_PACKET_SIZE, and NFD_LOG_WARN.
void nfd::UdpChannel::connect | ( | const udp::Endpoint & | remoteEndpoint, |
ndn::nfd::FacePersistency | persistency, | ||
const FaceCreatedCallback & | onFaceCreated, | ||
const ConnectFailedCallback & | onConnectFailed | ||
) |
Create a face by establishing connection to remote endpoint.
UdpChannel::Error | if bind or connect on the socket fail |
Definition at line 69 of file udp-channel.cpp.
References NFD_LOG_WARN.
size_t nfd::UdpChannel::size | ( | ) | const |
Get number of faces in the channel.
Definition at line 91 of file udp-channel.cpp.
References ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, ndn::nfd::FACE_PERSISTENCY_PERMANENT, nfd::getGlobalIoService(), ndn::MAX_NDN_PACKET_SIZE, NFD_LOG_DEBUG, NFD_LOG_TRACE, and NFD_LOG_WARN.
|
inline |
Definition at line 132 of file udp-channel.hpp.
Referenced by listen().