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

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

Inheritance diagram for IcmpAsyncSocket:
Collaboration diagram for IcmpAsyncSocket:

Static Public Member Functions

static void SetUpTestCase ()
 set up test case.
 

Protected Member Functions

void SetUp () override
 Sets up the test fixture.
 

Static Protected Member Functions

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 Icmp::Endpoint &from, bool more)
 report a read completion and the endpoint it came from to the test thread.
 
static void onRead (const std::error_code &ec, const char *data, size_t size, 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 bool wait (int expected)
 wait for the expected number of completions.
 
static void onReportMulti (const std::error_code &ec, const char *data, size_t size, const Icmp::Endpoint &from, bool more)
 report a multishot completion to the test thread.
 
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 Icmp::Endpoint _from
 endpoint the last datagram was received from.
 
static bool _more = false
 last reported multishot state.
 
static char _data [sizeof(struct icmphdr)] = {}
 echo request sent by the tests.
 
static const std::string _host = "127.0.0.1"
 host.
 
static Icmp::AsyncSocket * _current = nullptr
 socket used by the resubmitting handler.
 
static int _rearms = 0
 number of resubmissions left to perform from a handler.
 
static const std::chrono::milliseconds _timeout {1000}
 timeout.
 

Detailed Description

Class used to test the icmp asynchronous datagram socket API.

Member Function Documentation

◆ onRead()

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

handler resubmitting a read from within itself.

◆ onReport()

static void IcmpAsyncSocket::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 IcmpAsyncSocket::onReportFrom ( const std::error_code & ec,
const char * data,
size_t size,
const Icmp::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 IcmpAsyncSocket::onReportMulti ( const std::error_code & ec,
const char * data,
size_t size,
const Icmp::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 IcmpAsyncSocket::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 IcmpAsyncSocket::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 IcmpAsyncSocket::onWrite ( const std::error_code & ec,
size_t size )
inlinestaticprotected

handler resubmitting a write from within itself.

◆ onWriteAndClose()

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

handler closing the socket from within itself.

◆ SetUp()

void IcmpAsyncSocket::SetUp ( )
inlineoverrideprotected

Sets up the test fixture.

◆ SetUpTestCase()

static void IcmpAsyncSocket::SetUpTestCase ( )
inlinestatic

set up test case.

◆ wait()

static bool IcmpAsyncSocket::wait ( int expected)
inlinestaticprotected

wait for the expected number of completions.

Parameters
expectednumber of completions to wait for.
Returns
true on success, false on timeout.

Member Data Documentation

◆ _buf

char IcmpAsyncSocket::_buf = {}
staticprotected

read buffer.

◆ _code

std::error_code IcmpAsyncSocket::_code
staticprotected

last reported error.

◆ _completions

int IcmpAsyncSocket::_completions = 0
staticprotected

number of completions reported.

◆ _cond

Condition IcmpAsyncSocket::_cond
staticprotected

condition variable.

◆ _current

Icmp::AsyncSocket * IcmpAsyncSocket::_current = nullptr
staticprotected

socket used by the resubmitting handler.

◆ _data

char IcmpAsyncSocket::_data = {}
staticprotected

echo request sent by the tests.

◆ _from

Icmp::Endpoint IcmpAsyncSocket::_from
staticprotected

endpoint the last datagram was received from.

◆ _host

const std::string IcmpAsyncSocket::_host = "127.0.0.1"
staticprotected

host.

◆ _more

bool IcmpAsyncSocket::_more = false
staticprotected

last reported multishot state.

◆ _mut

Mutex IcmpAsyncSocket::_mut
staticprotected

condition mutex.

◆ _rearms

int IcmpAsyncSocket::_rearms = 0
staticprotected

number of resubmissions left to perform from a handler.

◆ _timeout

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

timeout.

◆ _transferred

size_t IcmpAsyncSocket::_transferred = 0
staticprotected

number of bytes reported by the last completion.


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