ndn::UnixTransport Class Reference

a transport using Unix stream socket More...

#include <ndn-cxx/transport/unix-transport.hpp>

+ Inheritance diagram for ndn::UnixTransport:
+ Collaboration diagram for ndn::UnixTransport:

Public Types

using ErrorCallback = std::function< void()>
 
using ReceiveCallback = std::function< void(const Block &wire)>
 

Public Member Functions

 UnixTransport (const std::string &unixSocket)
 
 ~UnixTransport () override
 
void close () override
 Close the connection. More...
 
void connect (boost::asio::io_service &ioService, ReceiveCallback receiveCallback) override
 Asynchronously open the connection. More...
 
bool isConnected () const noexcept
 Return whether the transport is connected. More...
 
bool isReceiving () const noexcept
 
void pause () override
 Pause the transport, canceling all pending operations. More...
 
void resume () override
 Resume the transport. More...
 
void send (const Block &wire) override
 Send a TLV block through the transport. More...
 

Static Public Member Functions

static shared_ptr< UnixTransportcreate (const std::string &uri)
 Create transport with parameters defined in URI. More...
 

Protected Attributes

boost::asio::io_service * m_ioService = nullptr
 
bool m_isConnected = false
 
bool m_isReceiving = false
 
ReceiveCallback m_receiveCallback
 

Detailed Description

a transport using Unix stream socket

Definition at line 40 of file unix-transport.hpp.

Member Typedef Documentation

◆ ErrorCallback

using ndn::Transport::ErrorCallback = std::function<void()>
inherited

Definition at line 47 of file transport.hpp.

◆ ReceiveCallback

using ndn::Transport::ReceiveCallback = std::function<void(const Block& wire)>
inherited

Definition at line 46 of file transport.hpp.

Constructor & Destructor Documentation

◆ UnixTransport()

ndn::UnixTransport::UnixTransport ( const std::string &  unixSocket)
explicit

Definition at line 34 of file unix-transport.cpp.

◆ ~UnixTransport()

ndn::UnixTransport::~UnixTransport ( )
overridedefault

Member Function Documentation

◆ close()

void ndn::UnixTransport::close ( )
overridevirtual

Close the connection.

Implements ndn::Transport.

Definition at line 100 of file unix-transport.cpp.

◆ connect()

void ndn::UnixTransport::connect ( boost::asio::io_service &  ioService,
ReceiveCallback  receiveCallback 
)
overridevirtual

Asynchronously open the connection.

Parameters
ioServiceio_service to create socket on
receiveCallbackcallback function when a TLV block is received; must not be empty
Exceptions
boost::system::system_errorconnection cannot be established

Reimplemented from ndn::Transport.

Definition at line 80 of file unix-transport.cpp.

◆ create()

shared_ptr< UnixTransport > ndn::UnixTransport::create ( const std::string &  uri)
static

Create transport with parameters defined in URI.

Exceptions
Transport::Errorincorrect URI or unsupported protocol is specified

Definition at line 74 of file unix-transport.cpp.

◆ isConnected()

bool ndn::Transport::isConnected ( ) const
inlinenoexceptinherited

Return whether the transport is connected.

Definition at line 95 of file transport.hpp.

◆ isReceiving()

bool ndn::Transport::isReceiving ( ) const
inlinenoexceptinherited
Return values
trueincoming packets are expected, the receive callback will be invoked
falseincoming packets are not expected, the receive callback will not be invoked

Definition at line 105 of file transport.hpp.

◆ pause()

void ndn::UnixTransport::pause ( )
overridevirtual

Pause the transport, canceling all pending operations.

Postcondition
the receive callback will not be invoked
Note
This operation has no effect if the transport has been paused, or when the connection is being established.

Implements ndn::Transport.

Definition at line 109 of file unix-transport.cpp.

◆ resume()

void ndn::UnixTransport::resume ( )
overridevirtual

Resume the transport.

Postcondition
the receive callback will be invoked
Note
This operation has no effect if the transport is not paused, or when the connection is being established.

Implements ndn::Transport.

Definition at line 118 of file unix-transport.cpp.

◆ send()

void ndn::UnixTransport::send ( const Block block)
overridevirtual

Send a TLV block through the transport.

Implements ndn::Transport.

Definition at line 93 of file unix-transport.cpp.

Member Data Documentation

◆ m_ioService

boost::asio::io_service* ndn::Transport::m_ioService = nullptr
protectedinherited

Definition at line 111 of file transport.hpp.

◆ m_isConnected

bool ndn::Transport::m_isConnected = false
protectedinherited

Definition at line 113 of file transport.hpp.

◆ m_isReceiving

bool ndn::Transport::m_isReceiving = false
protectedinherited

Definition at line 114 of file transport.hpp.

◆ m_receiveCallback

ReceiveCallback ndn::Transport::m_receiveCallback
protectedinherited

Definition at line 112 of file transport.hpp.