NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::TcpTransport Class Reference

a transport using TCP socket More...

#include <tcp-transport.hpp>

Inheritance diagram for ndn::TcpTransport:
Collaboration diagram for ndn::TcpTransport:

Public Member Functions

 TcpTransport (const std::string &host, const std::string &port="6363")
 
 ~TcpTransport ()
 
virtual void connect (boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback) override
 asynchronously open the connection More...
 
virtual void close () override
 Close the connection. More...
 
virtual void pause () override
 pause the transport More...
 
virtual void resume () override
 resume the transport More...
 
virtual void send (const Block &wire) override
 send a TLV block through the transport More...
 
virtual void send (const Block &header, const Block &payload) override
 send two memory blocks through the transport More...
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE std::string getSocketHostAndPortFromUri (const std::string &uri)
 
- Public Member Functions inherited from ndn::Transport
 Transport ()
 
virtual ~Transport ()=default
 
bool isConnected () const
 
bool isReceiving () const
 

Static Public Member Functions

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

Public Attributes

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE __pad0__: static std::pair<std::string
 

Friends

class StreamTransportImpl< TcpTransport, boost::asio::ip::tcp >
 
class StreamTransportWithResolverImpl< TcpTransport, boost::asio::ip::tcp >
 

Additional Inherited Members

- Public Types inherited from ndn::Transport
typedef function< void(const Block &wire)> ReceiveCallback
 
typedef function< void()> ErrorCallback
 
- Protected Member Functions inherited from ndn::Transport
void receive (const Block &wire)
 invoke the receive callback More...
 
- Protected Attributes inherited from ndn::Transport
boost::asio::io_service * m_ioService
 
bool m_isConnected
 
bool m_isReceiving
 
ReceiveCallback m_receiveCallback
 

Detailed Description

a transport using TCP socket

Definition at line 46 of file tcp-transport.hpp.

Constructor & Destructor Documentation

◆ TcpTransport()

ndn::TcpTransport::TcpTransport ( const std::string &  host,
const std::string &  port = "6363" 
)
explicit

Definition at line 28 of file tcp-transport.cpp.

References ~TcpTransport().

◆ ~TcpTransport()

ndn::TcpTransport::~TcpTransport ( )
default

Referenced by TcpTransport().

Member Function Documentation

◆ connect()

void ndn::TcpTransport::connect ( boost::asio::io_service &  ioService,
const 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 77 of file tcp-transport.cpp.

References ndn::Transport::connect().

◆ close()

void ndn::TcpTransport::close ( )
overridevirtual

Close the connection.

Implements ndn::Transport.

Definition at line 105 of file tcp-transport.cpp.

◆ pause()

void ndn::TcpTransport::pause ( )
overridevirtual

pause the transport

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

Implements ndn::Transport.

Definition at line 113 of file tcp-transport.cpp.

◆ resume()

void ndn::TcpTransport::resume ( )
overridevirtual

resume the transport

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

Implements ndn::Transport.

Definition at line 121 of file tcp-transport.cpp.

◆ send() [1/2]

void ndn::TcpTransport::send ( const Block wire)
overridevirtual

send a TLV block through the transport

Implements ndn::Transport.

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

◆ send() [2/2]

void ndn::TcpTransport::send ( const Block header,
const Block payload 
)
overridevirtual

send two memory blocks through the transport

Scatter/gather API is utilized to send two non-consecutive memory blocks together (as part of the same message in datagram-oriented transports).

Implements ndn::Transport.

Definition at line 98 of file tcp-transport.cpp.

◆ create()

shared_ptr< TcpTransport > ndn::TcpTransport::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 37 of file tcp-transport.cpp.

References getSocketHostAndPortFromUri().

◆ getSocketHostAndPortFromUri()

std::pair< std::string, std::string > ndn::TcpTransport::getSocketHostAndPortFromUri ( const std::string &  uri)

Friends And Related Function Documentation

◆ StreamTransportImpl< TcpTransport, boost::asio::ip::tcp >

friend class StreamTransportImpl< TcpTransport, boost::asio::ip::tcp >
friend

Definition at line 88 of file tcp-transport.hpp.

◆ StreamTransportWithResolverImpl< TcpTransport, boost::asio::ip::tcp >

friend class StreamTransportWithResolverImpl< TcpTransport, boost::asio::ip::tcp >
friend

Definition at line 89 of file tcp-transport.hpp.

Member Data Documentation

◆ __pad0__

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::TcpTransport::__pad0__

Definition at line 80 of file tcp-transport.hpp.


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