Public Member Functions | List of all members
ndn::AsyncSocketTransport< AsioProtocol > Class Template Reference

AsyncSocketTransport is a helper template class for AsyncTcpTransport and AsyncUnixTransport to implement common socket communication tasks using Boost's asio io_service. More...

#include <async-socket-transport.hpp>

Public Member Functions

 AsyncSocketTransport (boost::asio::io_service &ioService)
 Create an AsyncSocketTransport in the unconnected state. More...
 
void connect (const typename AsioProtocol::endpoint &endPoint, ElementListener &elementListener, const Transport::OnConnected &onConnected)
 Connect according to the info in connectionInfo, and use elementListener. More...
 
void send (const uint8_t *data, size_t dataLength)
 Set data to the host. More...
 
bool getIsConnected ()
 
void close ()
 Close the connection to the host.
 

Detailed Description

template<class AsioProtocol>
class ndn::AsyncSocketTransport< AsioProtocol >

AsyncSocketTransport is a helper template class for AsyncTcpTransport and AsyncUnixTransport to implement common socket communication tasks using Boost's asio io_service.

The template class AsioProtocol should be boost::asio::ip::tcp or boost::asio::local::stream_protocol (for a Unix socket). Boost uses template classes instead of base classes with override, so we implement all methods here in the header file.

Constructor & Destructor Documentation

template<class AsioProtocol >
ndn::AsyncSocketTransport< AsioProtocol >::AsyncSocketTransport ( boost::asio::io_service &  ioService)
inline

Create an AsyncSocketTransport in the unconnected state.

This will use the ioService to create the connection and communicate asynchronously.

Parameters
ioServiceThe asio io_service. It is the responsibility of the application to start and stop the service.

Member Function Documentation

template<class AsioProtocol >
void ndn::AsyncSocketTransport< AsioProtocol >::connect ( const typename AsioProtocol::endpoint & endPoint  ,
ElementListener elementListener,
const Transport::OnConnected &  onConnected 
)
inline

Connect according to the info in connectionInfo, and use elementListener.

To be thread-safe, this must be called from a dispatch to the ioService which was given to the constructor, as is done by ThreadsafeFace.

Parameters
endPointThe asio endpoint for the protocol containing the connection info.
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.
template<class AsioProtocol >
void ndn::AsyncSocketTransport< AsioProtocol >::send ( const uint8_t *  data,
size_t  dataLength 
)
inline

Set data to the host.

To be thread-safe, this must be called from a dispatch to the ioService which was given to the constructor, as is done by ThreadsafeFace.

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

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