join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
UnixAsyncDatagramSocket Class Reference

Class used to test the unix asynchronous datagram socket API. More...

Inheritance diagram for UnixAsyncDatagramSocket:
Collaboration diagram for UnixAsyncDatagramSocket:

Protected Member Functions

void SetUp () override
 Sets up the test fixture.
 
void TearDown () override
 Tears down the test fixture.
 

Static Protected Member Functions

static UnixDgram::AsyncSocket & server ()
 get the echo server socket.
 
static void onEchoRead (const std::error_code &ec, const char *data, size_t size, const UnixDgram::Endpoint &from, bool more)
 send back the datagram received by the echo server.
 
static void onEchoWrite (const std::error_code &ec, size_t size)
 wait for the next datagram to echo.
 
static void onReport (const std::error_code &ec, size_t size)
 report a completion to the test thread.
 
static void onReportRead (const std::error_code &ec, const char *data, size_t size, bool more)
 report a read completion to the test thread.
 
static void onReportFrom (const std::error_code &ec, const char *data, size_t size, const UnixDgram::Endpoint &from, bool more)
 report a read completion and the endpoint it came from to the test thread.
 
static UnixDgram::AsyncSocket & moved ()
 get the socket receiving the move performed from a handler.
 
static void onReadAndMove (const std::error_code &ec, const char *data, size_t size, const UnixDgram::Endpoint &from, bool more)
 handler moving the socket from within itself.
 
static void onReportMulti (const std::error_code &ec, const char *data, size_t size, const UnixDgram::Endpoint &from, bool more)
 report a multishot completion to the test thread.
 
static void onRead (const std::error_code &ec, const char *data, size_t size, const UnixDgram::Endpoint &from, bool more)
 handler resubmitting a read from within itself.
 
static void onWrite (const std::error_code &ec, size_t size)
 handler resubmitting a write from within itself.
 
static void onWriteAndClose (const std::error_code &ec, size_t size)
 handler closing the socket from within itself.
 
static void onReportWait (const std::error_code &ec, bool more)
 report a wait completion to the test thread.
 

Static Protected Attributes

static Mutex _mut
 condition mutex.
 
static Condition _cond
 condition variable.
 
static std::error_code _code
 last reported error.
 
static int _completions = 0
 number of completions reported.
 
static size_t _transferred = 0
 number of bytes reported by the last completion.
 
static char _buf [1024] = {}
 read buffer.
 
static UnixDgram::Endpoint _from
 endpoint the last datagram was received from.
 
static bool _more = false
 last reported multishot state.
 
static char _echobuf [1024] = {}
 buffer used by the echo server.
 
static UnixDgram::Endpoint _echofrom
 endpoint the echo server received the last datagram from.
 
static UnixDgram::AsyncSocket * _current = nullptr
 socket used by the resubmitting handler.
 
static int _rearms = 0
 number of resubmissions left to perform from a handler.
 
static UnixDgram::Endpoint _dest
 destination used by the resubmitting write handler.
 
static const std::string _serverpath = "/tmp/unixasyncdgramserver_test.sock"
 echo server path.
 
static const std::string _clientpath = "/tmp/unixasyncdgramclient_test.sock"
 client path.
 
static const std::string _senderpath = "/tmp/unixasyncdgramsender_test.sock"
 path used by the synchronous sender.
 
static const std::chrono::milliseconds _timeout {1000}
 timeout.
 

Detailed Description

Class used to test the unix asynchronous datagram socket API.

Member Function Documentation

◆ moved()

static UnixDgram::AsyncSocket & UnixAsyncDatagramSocket::moved ( )
inlinestaticprotected

get the socket receiving the move performed from a handler.

Returns
the socket receiving the move performed from a handler.

◆ onEchoRead()

static void UnixAsyncDatagramSocket::onEchoRead ( const std::error_code & ec,
const char * data,
size_t size,
const UnixDgram::Endpoint & from,
bool more )
inlinestaticprotected

send back the datagram received by the echo server.

Parameters
ecerror reported by the socket.
databuffer holding the data received.
sizenumber of bytes read.
fromendpoint the datagram was received from.
moretrue if the read stays armed.

◆ onEchoWrite()

static void UnixAsyncDatagramSocket::onEchoWrite ( const std::error_code & ec,
size_t size )
inlinestaticprotected

wait for the next datagram to echo.

Parameters
ecerror reported by the socket.
sizenumber of bytes written.

◆ onRead()

static void UnixAsyncDatagramSocket::onRead ( const std::error_code & ec,
const char * data,
size_t size,
const UnixDgram::Endpoint & from,
bool more )
inlinestaticprotected

handler resubmitting a read from within itself.

Parameters
ecerror reported by the socket.
databuffer holding the data received.
sizenumber of bytes read.
fromendpoint the datagram was received from.
moretrue if the read stays armed.

◆ onReadAndMove()

static void UnixAsyncDatagramSocket::onReadAndMove ( const std::error_code & ec,
const char * data,
size_t size,
const UnixDgram::Endpoint & from,
bool more )
inlinestaticprotected

handler moving the socket from within itself.

Parameters
ecerror reported by the socket.
databuffer holding the data received.
sizenumber of bytes read.
fromendpoint the datagram was received from.
moretrue if the read stays armed.

◆ onReport()

static void UnixAsyncDatagramSocket::onReport ( const std::error_code & ec,
size_t size )
inlinestaticprotected

report a completion to the test thread.

Parameters
ecerror reported by the socket.
sizenumber of bytes transferred.

◆ onReportFrom()

static void UnixAsyncDatagramSocket::onReportFrom ( const std::error_code & ec,
const char * data,
size_t size,
const UnixDgram::Endpoint & from,
bool more )
inlinestaticprotected

report a read completion and the endpoint it came from to the test thread.

Parameters
ecerror reported by the socket.
databuffer holding the data received.
sizenumber of bytes read.
fromendpoint the datagram was received from.
moretrue if the read stays armed.

◆ onReportMulti()

static void UnixAsyncDatagramSocket::onReportMulti ( const std::error_code & ec,
const char * data,
size_t size,
const UnixDgram::Endpoint & from,
bool more )
inlinestaticprotected

report a multishot completion to the test thread.

Parameters
ecerror reported by the socket.
databuffer holding the data received.
sizenumber of bytes read.
fromendpoint the datagram was received from.
moretrue if the read stays armed.

◆ onReportRead()

static void UnixAsyncDatagramSocket::onReportRead ( const std::error_code & ec,
const char * data,
size_t size,
bool more )
inlinestaticprotected

report a read completion to the test thread.

Parameters
ecerror reported by the socket.
databuffer holding the data received.
sizenumber of bytes read.
moretrue if the read stays armed.

◆ onReportWait()

static void UnixAsyncDatagramSocket::onReportWait ( const std::error_code & ec,
bool more )
inlinestaticprotected

report a wait completion to the test thread.

Parameters
ecerror reported by the socket.
moretrue if the wait stays armed.

◆ onWrite()

static void UnixAsyncDatagramSocket::onWrite ( const std::error_code & ec,
size_t size )
inlinestaticprotected

handler resubmitting a write from within itself.

Parameters
ecerror reported by the socket.
sizenumber of bytes written.

◆ onWriteAndClose()

static void UnixAsyncDatagramSocket::onWriteAndClose ( const std::error_code & ec,
size_t size )
inlinestaticprotected

handler closing the socket from within itself.

Parameters
ecerror reported by the socket.
sizenumber of bytes written.

◆ server()

static UnixDgram::AsyncSocket & UnixAsyncDatagramSocket::server ( )
inlinestaticprotected

get the echo server socket.

Returns
the echo server socket.

◆ SetUp()

void UnixAsyncDatagramSocket::SetUp ( )
inlineoverrideprotected

Sets up the test fixture.

◆ TearDown()

void UnixAsyncDatagramSocket::TearDown ( )
inlineoverrideprotected

Tears down the test fixture.

Member Data Documentation

◆ _buf

char UnixAsyncDatagramSocket::_buf = {}
staticprotected

read buffer.

◆ _clientpath

const std::string UnixAsyncDatagramSocket::_clientpath = "/tmp/unixasyncdgramclient_test.sock"
staticprotected

client path.

◆ _code

std::error_code UnixAsyncDatagramSocket::_code
staticprotected

last reported error.

◆ _completions

int UnixAsyncDatagramSocket::_completions = 0
staticprotected

number of completions reported.

◆ _cond

Condition UnixAsyncDatagramSocket::_cond
staticprotected

condition variable.

◆ _current

UnixDgram::AsyncSocket * UnixAsyncDatagramSocket::_current = nullptr
staticprotected

socket used by the resubmitting handler.

◆ _dest

UnixDgram::Endpoint UnixAsyncDatagramSocket::_dest
staticprotected

destination used by the resubmitting write handler.

◆ _echobuf

char UnixAsyncDatagramSocket::_echobuf = {}
staticprotected

buffer used by the echo server.

◆ _echofrom

UnixDgram::Endpoint UnixAsyncDatagramSocket::_echofrom
staticprotected

endpoint the echo server received the last datagram from.

◆ _from

UnixDgram::Endpoint UnixAsyncDatagramSocket::_from
staticprotected

endpoint the last datagram was received from.

◆ _more

bool UnixAsyncDatagramSocket::_more = false
staticprotected

last reported multishot state.

◆ _mut

Mutex UnixAsyncDatagramSocket::_mut
staticprotected

condition mutex.

◆ _rearms

int UnixAsyncDatagramSocket::_rearms = 0
staticprotected

number of resubmissions left to perform from a handler.

◆ _senderpath

const std::string UnixAsyncDatagramSocket::_senderpath = "/tmp/unixasyncdgramsender_test.sock"
staticprotected

path used by the synchronous sender.

◆ _serverpath

const std::string UnixAsyncDatagramSocket::_serverpath = "/tmp/unixasyncdgramserver_test.sock"
staticprotected

echo server path.

◆ _timeout

const std::chrono::milliseconds UnixAsyncDatagramSocket::_timeout {1000}
staticprotected

timeout.

◆ _transferred

size_t UnixAsyncDatagramSocket::_transferred = 0
staticprotected

number of bytes reported by the last completion.


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