NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
nfd::TcpChannel Class Reference

Class implementing TCP-based channel to create faces. More...

#include <tcp-channel.hpp>

Inheritance diagram for nfd::TcpChannel:
Collaboration diagram for nfd::TcpChannel:

Public Member Functions

 TcpChannel (const tcp::Endpoint &localEndpoint)
 Create TCP channel for the local endpoint. More...
 
void listen (const FaceCreatedCallback &onFaceCreated, const ConnectFailedCallback &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 FaceCreatedCallback &onFaceCreated, const ConnectFailedCallback &onConnectFailed, const time::seconds &timeout=time::seconds(4))
 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 FaceUrigetUri () 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)
 

Detailed Description

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 45 of file tcp-channel.hpp.

Constructor & Destructor Documentation

nfd::TcpChannel::TcpChannel ( const tcp::Endpoint localEndpoint)
explicit

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 36 of file tcp-channel.cpp.

References nfd::Channel::setUri().

Member Function Documentation

void nfd::TcpChannel::listen ( const FaceCreatedCallback onFaceCreated,
const ConnectFailedCallback 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.

Parameters
onFaceCreatedCallback to notify successful creation of the face
onAcceptFailedCallback to notify when channel fails (accept call returns an error)
backlogThe maximum length of the queue of pending incoming connections

Definition at line 45 of file tcp-channel.cpp.

References isListening(), and NFD_LOG_WARN.

void nfd::TcpChannel::connect ( const tcp::Endpoint remoteEndpoint,
const FaceCreatedCallback onFaceCreated,
const ConnectFailedCallback onConnectFailed,
const time::seconds &  timeout = time::seconds(4) 
)

Create a face by establishing connection to remote endpoint.

Definition at line 67 of file tcp-channel.cpp.

References nfd::getGlobalIoService(), and nfd::scheduler::schedule().

size_t nfd::TcpChannel::size ( ) const

Get number of faces in the channel.

Definition at line 91 of file tcp-channel.cpp.

References nfd::scheduler::cancel(), NFD_LOG_DEBUG, NFD_LOG_TRACE, and NFD_LOG_WARN.

bool nfd::TcpChannel::isListening ( ) const
inline

Definition at line 124 of file tcp-channel.hpp.

Referenced by listen().


The documentation for this class was generated from the following files: