NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
websocketpp::transport Namespace Reference

Transport policies provide network connectivity and timers. More...

Namespaces

 asio
 Transport policy that uses asio.
 
 debug
 Debug transport policy that is used for various mocking and stubbing duties in unit tests.
 
 error
 Generic transport related errors.
 
 iostream
 Transport policy that uses STL iostream for I/O and does not support timers.
 
 stub
 Stub transport policy that has no input or output.
 

Classes

struct  buffer
 A simple utility buffer class. More...
 

Typedefs

typedef lib::function< void(lib::error_code const &)> init_handler
 The type and signature of the callback passed to the init hook. More...
 
typedef lib::function< void(lib::error_code const &, size_t)> read_handler
 The type and signature of the callback passed to the read method. More...
 
typedef lib::function< void(lib::error_code const &)> write_handler
 The type and signature of the callback passed to the write method. More...
 
typedef lib::function< void(lib::error_code const &)> timer_handler
 The type and signature of the callback passed to the read method. More...
 
typedef lib::function< void(lib::error_code const &)> shutdown_handler
 The type and signature of the callback passed to the shutdown method. More...
 
typedef lib::function< void()> interrupt_handler
 The type and signature of the callback passed to the interrupt method. More...
 
typedef lib::function< void()> dispatch_handler
 The type and signature of the callback passed to the dispatch method. More...
 
typedef lib::function< void(lib::error_code const &)> accept_handler
 The type and signature of the callback passed to the accept method. More...
 
typedef lib::function< void(lib::error_code const &)> connect_handler
 The type and signature of the callback passed to the connect method. More...
 

Detailed Description

Transport policies provide network connectivity and timers.

Connection Interface

Transport connection components needs to provide:

init
void init(init_handler handler)
Called once shortly after construction to give the policy the chance to perform one time initialization. When complete, the policy must call the supplied init_handler to continue setup. The handler takes one argument with the error code if any. If an error is returned here setup will fail and the connection will be aborted or terminated.

WebSocket++ will call init only once. The transport must call handler exactly once.

async_read_at_least
void async_read_at_least(size_t num_bytes, char *buf, size_t len, read_handler handler)
start an async read for at least num_bytes and at most len bytes into buf. Call handler when done with number of bytes read.

WebSocket++ promises to have only one async_read_at_least in flight at a time. The transport must promise to only call read_handler once per async read.

async_write
void async_write(const char* buf, size_t len, write_handler handler)
void async_write(std::vector<buffer> & bufs, write_handler handler)
Start a write of all of the data in buf or bufs. In second case data is written sequentially and in place without copying anything to a temporary location.

Websocket++ promises to have only one async_write in flight at a time. The transport must promise to only call the write_handler once per async write

set_handle
void set_handle(connection_hdl hdl)
Called by WebSocket++ to let this policy know the hdl to the connection. It may be stored for later use or ignored/discarded. This handle should be used if the policy adds any connection handlers. Connection handlers must be called with the handle as the first argument so that the handler code knows which connection generated the callback.

set_timer
timer_ptr set_timer(long duration, timer_handler handler)
WebSocket++ uses the timers provided by the transport policy as the implementation of timers is often highly coupled with the implementation of the networking event loops.

Transport timer support is an optional feature. A transport method may elect to implement a dummy timer object and have this method return an empty pointer. If so, all timer related features of WebSocket++ core will be disabled. This includes many security features designed to prevent denial of service attacks. Use timer-free transport policies with caution.

get_remote_endpoint
std::string get_remote_endpoint()
retrieve address of remote endpoint

is_secure
void is_secure()
whether or not the connection to the remote endpoint is secure

dispatch
lib::error_code dispatch(dispatch_handler handler): invoke handler within the transport's event system if it uses one. Otherwise, this method should simply call handler immediately.

async_shutdown
void async_shutdown(shutdown_handler handler)
Perform any cleanup necessary (if any). Call handler when complete.

Endpoint Interface

Transport endpoint components needs to provide:

init
lib::error_code init(transport_con_ptr tcon)
init is called by an endpoint once for each newly created connection. It's purpose is to give the transport policy the chance to perform any transport specific initialization that couldn't be done via the default constructor.

is_secure
bool is_secure() const
Test whether the transport component of this endpoint is capable of secure connections.

async_connect
void async_connect(transport_con_ptr tcon, uri_ptr location, connect_handler handler)
Initiate a connection to location using the given connection tcon. tcon is a pointer to the transport connection component of the connection. When complete, handler should be called with the the connection's connection_hdl and any error that occurred.

init_logging void init_logging(const lib::shared_ptr<alog_type>& a, const lib::shared_ptr<elog_type>& e)
Called once after construction to provide pointers to the endpoint's access and error loggers. These may be stored and used to log messages or ignored.

Typedef Documentation

◆ init_handler

typedef lib::function<void(lib::error_code const &)> websocketpp::transport::init_handler

The type and signature of the callback passed to the init hook.

Definition at line 117 of file connection.hpp.

◆ read_handler

typedef lib::function<void(lib::error_code const &,size_t)> websocketpp::transport::read_handler

The type and signature of the callback passed to the read method.

Definition at line 120 of file connection.hpp.

◆ write_handler

typedef lib::function<void(lib::error_code const &)> websocketpp::transport::write_handler

The type and signature of the callback passed to the write method.

Definition at line 123 of file connection.hpp.

◆ timer_handler

typedef lib::function<void(lib::error_code const &)> websocketpp::transport::timer_handler

The type and signature of the callback passed to the read method.

Definition at line 126 of file connection.hpp.

◆ shutdown_handler

typedef lib::function<void(lib::error_code const &)> websocketpp::transport::shutdown_handler

The type and signature of the callback passed to the shutdown method.

Definition at line 129 of file connection.hpp.

◆ interrupt_handler

typedef lib::function<void()> websocketpp::transport::interrupt_handler

The type and signature of the callback passed to the interrupt method.

Definition at line 132 of file connection.hpp.

◆ dispatch_handler

typedef lib::function<void()> websocketpp::transport::dispatch_handler

The type and signature of the callback passed to the dispatch method.

Definition at line 135 of file connection.hpp.

◆ accept_handler

typedef lib::function<void(lib::error_code const &)> websocketpp::transport::accept_handler

The type and signature of the callback passed to the accept method.

Definition at line 69 of file endpoint.hpp.

◆ connect_handler

typedef lib::function<void(lib::error_code const &)> websocketpp::transport::connect_handler

The type and signature of the callback passed to the connect method.

Definition at line 72 of file endpoint.hpp.