Classes | Public Types | Public Member Functions | List of all members
ndn::Transport Class Referenceabstract
Inheritance diagram for ndn::Transport:
ndn::AsyncTcpTransport ndn::AsyncUnixTransport ndn::TcpTransport ndn::UdpTransport ndn::UnixTransport

Classes

class  ConnectionInfo
 A Transport::ConnectionInfo is a base class for connection information used by subclasses of Transport. More...
 

Public Types

typedef func_lib::function< void()> OnConnected
 

Public Member Functions

virtual bool isLocal (const Transport::ConnectionInfo &connectionInfo)
 Determine whether this transport connecting according to connectionInfo is to a node on the current machine. More...
 
virtual bool isAsync ()
 Check if this transport is async where connect needs to use the onConnected callback. More...
 
virtual void connect (const Transport::ConnectionInfo &connectionInfo, ElementListener &elementListener, const OnConnected &onConnected)
 Connect according to the info in ConnectionInfo, and processEvents() will use elementListener. More...
 
virtual void send (const uint8_t *data, size_t dataLength)
 Send data to the host. More...
 
void send (const std::vector< uint8_t > &data)
 
virtual void processEvents ()=0
 Process any data to receive. More...
 
virtual bool getIsConnected ()
 
virtual void close ()
 Close the connection. More...
 

Member Function Documentation

void ndn::Transport::close ( )
virtual

Close the connection.

This base class implementation does nothing, but your derived class can override.

Reimplemented in ndn::AsyncTcpTransport, ndn::TcpTransport, ndn::AsyncUnixTransport, ndn::UdpTransport, and ndn::UnixTransport.

void ndn::Transport::connect ( const Transport::ConnectionInfo connectionInfo,
ElementListener elementListener,
const OnConnected &  onConnected 
)
virtual

Connect according to the info in ConnectionInfo, and processEvents() will use elementListener.

Parameters
connectionInfoA reference to an object of a subclass of ConnectionInfo.
elementListenerNot a shared_ptr because we assume that it will remain valid during the life of this object.
onConnectedThis calls onConnected() when the connection is established.

Reimplemented in ndn::AsyncTcpTransport, ndn::TcpTransport, ndn::AsyncUnixTransport, ndn::UdpTransport, and ndn::UnixTransport.

bool ndn::Transport::isAsync ( )
virtual

Check if this transport is async where connect needs to use the onConnected callback.

Returns
True if transport connect is async, false if not.

Reimplemented in ndn::AsyncTcpTransport, ndn::TcpTransport, ndn::AsyncUnixTransport, ndn::UdpTransport, and ndn::UnixTransport.

bool ndn::Transport::isLocal ( const Transport::ConnectionInfo connectionInfo)
virtual

Determine whether this transport connecting according to connectionInfo is to a node on the current machine.

This affects the processing of Face.registerPrefix(): if the NFD is local, registration occurs with the '/localhost/nfd...' prefix; if non-local, the library will attempt to use remote prefix registration using '/localhop/nfd...'

Parameters
connectionInfoA ConnectionInfo with the host to check.
Returns
True if the host is local, false if not.

Reimplemented in ndn::AsyncTcpTransport, ndn::TcpTransport, ndn::AsyncUnixTransport, ndn::UdpTransport, and ndn::UnixTransport.

void ndn::Transport::processEvents ( )
pure virtual

Process any data to receive.

For each element received, call elementListener.onReceivedElement. This is non-blocking and will return immediately if there is no data to receive. You should normally not call this directly since it is called by Face.processEvents.

Exceptions
Thismay throw an exception for reading data or in the callback for processing the data. If you call this from an main event loop, you may want to catch and log/disregard all exceptions.

Implemented in ndn::AsyncTcpTransport, ndn::TcpTransport, ndn::AsyncUnixTransport, ndn::UdpTransport, and ndn::UnixTransport.

void ndn::Transport::send ( const uint8_t *  data,
size_t  dataLength 
)
virtual

Send data to the host.

Parameters
dataA pointer to the buffer of data to send.
dataLengthThe number of bytes in data.

Reimplemented in ndn::AsyncTcpTransport, ndn::AsyncUnixTransport, ndn::TcpTransport, ndn::UdpTransport, and ndn::UnixTransport.


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