Class NetioReceiver

Class Documentation

class NetioReceiver

The receiver class is responsible for receiving data from a sender.

On data reception, the receiver will call the on_data_cb callback with the received decoded data and/or the on_buffer_cb callback with the received buffer.

Public Functions

explicit NetioReceiver(const NetioReceiverConfig &config, std::shared_ptr<BaseEventLoop> evloop)

Constructor for the NetioReceiver.

Parameters:
  • config – Configuration of the network backend and buffers

  • evloop – Pointer to the event loop that schedules netio ops

NetioReceiver(const NetioReceiver&) = delete
NetioReceiver(const NetioReceiver&&) = delete
NetioReceiver() = delete
NetioReceiver &operator=(const NetioReceiver&) = delete
NetioReceiver &operator=(const NetioReceiver&&) = delete
~NetioReceiver()
unsigned short listen(const EndPointAddress &ep, const ConnectionParametersRecv &conn_params)

Listen for incoming connections.

Parameters:
  • ep – Local endpoint address to listen on

  • conn_params – Configuration for the opened receive endpoints

Returns:

The port of which we are listening (assigned by the system if 0 was passed)

void close(const EndPointAddress &ep)

Close a listening endpoint.

Stop listening on the provided endpoint. Also closes all receive endpoints spawned by this listener.

Parameters:

ep – Address of the endpoint

void set_on_data_cb(CbMessageReceived cb)

Set a callback function to be called when data are received.

This callback is the main purpose of this class. Invoked for each decoded message inside a buffer.

Parameters:

cb – Callback function

void set_on_buffer_cb(CbBufferReceived cb)

Set a callback function to be called when data are received.

This callback is the main purpose of this class. Invoked with the entire buffer.

Parameters:

cb – Callback function

void set_on_connection_established_cb(OnConnectionEstablishedSimpleCb cb)

Set a callback function to be called when a connection is established.

Parameters:

cb – Callback function

void set_on_connection_closed_cb(OnConnectionClosedCb cb)

Set a callback function to be called when a connection is closed.

Parameters:

cb – Callback function