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

Class used to test the raw asynchronous socket API. More...

Inheritance diagram for RawAsyncSocket:
Collaboration diagram for RawAsyncSocket:

Static Public Member Functions

static void SetUpTestCase ()
 set up test case.
 

Protected Member Functions

void SetUp () override
 Sets up the test fixture.
 
struct __attribute__ ((packed)) Packet
 Raw packet.
 

Static Protected Member Functions

static void onCompletion (const std::error_code &ec, size_t size)
 report a completion to the waiting test.
 
static void onReadCompletion (const std::error_code &ec, const char *data, size_t size, bool more)
 report a read completion to the waiting test.
 
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 void onReportMulti (const std::error_code &ec, const char *data, size_t size, bool more)
 report a multishot completion to the waiting test.
 
static bool wait (int expected)
 wait for the expected number of completions.
 
static void onReportWait (const std::error_code &ec, bool more)
 report a wait completion to the test thread.
 

Static Protected Attributes

static Mutex _mut
 mutex.
 
static Condition _cond
 condition variable.
 
static std::error_code _code
 error reported by the last completion.
 
static int _completions = 0
 number of completions reported.
 
static size_t _transferred = 0
 number of bytes reported by the last completion.
 
static Packet _packet
 packet.
 
static char _buf [2048] = {}
 read buffer.
 
static const std::string _interface = "lo"
 interface.
 
static Raw::AsyncSocket * _current = nullptr
 socket used by the resubmitting handler.
 
static bool _more = false
 last reported multishot state.
 
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 raw asynchronous socket API.

Member Function Documentation

◆ __attribute__()

struct RawAsyncSocket::__attribute__ ( (packed) )
inlineprotected

Raw packet.

◆ onCompletion()

static void RawAsyncSocket::onCompletion ( const std::error_code & ec,
size_t size )
inlinestaticprotected

report a completion to the waiting test.

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

◆ onRead()

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

handler resubmitting a read from within itself.

◆ onReadCompletion()

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

report a read completion to the waiting test.

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

◆ onReportMulti()

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

report a multishot completion to the waiting test.

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

◆ onReportWait()

static void RawAsyncSocket::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 RawAsyncSocket::onWrite ( const std::error_code & ec,
size_t size )
inlinestaticprotected

handler resubmitting a write from within itself.

◆ onWriteAndClose()

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

handler closing the socket from within itself.

◆ SetUp()

void RawAsyncSocket::SetUp ( )
inlineoverrideprotected

Sets up the test fixture.

◆ SetUpTestCase()

static void RawAsyncSocket::SetUpTestCase ( )
inlinestatic

set up test case.

◆ wait()

static bool RawAsyncSocket::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 RawAsyncSocket::_buf = {}
staticprotected

read buffer.

◆ _code

std::error_code RawAsyncSocket::_code
staticprotected

error reported by the last completion.

◆ _completions

int RawAsyncSocket::_completions = 0
staticprotected

number of completions reported.

◆ _cond

Condition RawAsyncSocket::_cond
staticprotected

condition variable.

◆ _current

Raw::AsyncSocket * RawAsyncSocket::_current = nullptr
staticprotected

socket used by the resubmitting handler.

◆ _interface

const std::string RawAsyncSocket::_interface = "lo"
staticprotected

interface.

◆ _more

bool RawAsyncSocket::_more = false
staticprotected

last reported multishot state.

◆ _mut

Mutex RawAsyncSocket::_mut
staticprotected

mutex.

◆ _packet

RawAsyncSocket::Packet RawAsyncSocket::_packet
staticprotected

packet.

◆ _rearms

int RawAsyncSocket::_rearms = 0
staticprotected

number of resubmissions left to perform from a handler.

◆ _timeout

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

timeout.

◆ _transferred

size_t RawAsyncSocket::_transferred = 0
staticprotected

number of bytes reported by the last completion.


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