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

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

Inheritance diagram for UnixAsyncStreamSocket:
Collaboration diagram for UnixAsyncStreamSocket:

Protected Member Functions

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

Static Protected Member Functions

static void TearDownTestSuite ()
 Tears down the test suite.
 
static UnixStream::AsyncSocket & peer ()
 get the socket accepted by the echo server.
 
static void onEchoRead (const std::error_code &ec, const char *data, size_t size, bool more)
 receive the data to send back.
 
static void onEchoWrite (const std::error_code &ec, size_t size)
 send back the data received by the echo server.
 
static void onEchoAccept (UnixStream::Socket &&sock, const std::error_code &ec, bool more)
 adopt the socket accepted by the echo server.
 
static void onWrite (const std::error_code &ec, size_t size)
 handler resubmitting a write from within itself.
 
static void onConnect (const std::error_code &ec)
 handler retrying the connection 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 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 onReportWait (const std::error_code &ec, bool more)
 report a wait completion to the test thread.
 

Protected Attributes

UnixStream::AsyncAcceptor _server
 echo server.
 

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 bool _more = false
 last reported multishot state.
 
static char _echobuf [1024] = {}
 buffer used by the echo server.
 
static UnixStream::AsyncSocket * _current = nullptr
 socket used by the resubmitting handler.
 
static int _rearms = 0
 number of resubmissions left to perform from the read handler.
 
static const std::string _serverpath = "/tmp/unixasyncserver_test.sock"
 path.
 
static const std::string _clientpath = "/tmp/unixasyncclient_test.sock"
 
static const std::string _stallpath = "/tmp/unixasyncstall_test.sock"
 
static const std::chrono::milliseconds _timeout {1000}
 timeout.
 

Detailed Description

Class used to test the unix asynchronous stream socket API.

Member Function Documentation

◆ onConnect()

static void UnixAsyncStreamSocket::onConnect ( const std::error_code & ec)
inlinestaticprotected

handler retrying the connection from within itself.

Parameters
ecerror reported by the socket.

◆ onEchoAccept()

static void UnixAsyncStreamSocket::onEchoAccept ( UnixStream::Socket && sock,
const std::error_code & ec,
bool more )
inlinestaticprotected

adopt the socket accepted by the echo server.

Parameters
sockaccepted socket.
ecerror reported by the acceptor.
moretrue if the acceptation stays armed.

◆ onEchoRead()

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

receive the data to send back.

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

◆ onEchoWrite()

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

send back the data received by the echo server.

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

◆ onRead()

static void UnixAsyncStreamSocket::onRead ( const std::error_code & ec,
const char * data,
size_t size,
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.
moretrue if the read stays armed.

◆ onReportMulti()

static void UnixAsyncStreamSocket::onReportMulti ( const std::error_code & ec,
const char * data,
size_t size,
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.
moretrue if the read stays armed.

◆ onReportWait()

static void UnixAsyncStreamSocket::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 UnixAsyncStreamSocket::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.

◆ peer()

static UnixStream::AsyncSocket & UnixAsyncStreamSocket::peer ( )
inlinestaticprotected

get the socket accepted by the echo server.

Returns
the socket accepted by the echo server.

◆ SetUp()

void UnixAsyncStreamSocket::SetUp ( )
inlineoverrideprotected

Sets up the test fixture.

◆ TearDown()

void UnixAsyncStreamSocket::TearDown ( )
inlineoverrideprotected

Tears down the test fixture.

◆ TearDownTestSuite()

static void UnixAsyncStreamSocket::TearDownTestSuite ( )
inlinestaticprotected

Tears down the test suite.

Member Data Documentation

◆ _buf

char UnixAsyncStreamSocket::_buf = {}
staticprotected

read buffer.

◆ _clientpath

const std::string UnixAsyncStreamSocket::_clientpath = "/tmp/unixasyncclient_test.sock"
staticprotected

◆ _code

std::error_code UnixAsyncStreamSocket::_code
staticprotected

last reported error.

◆ _completions

int UnixAsyncStreamSocket::_completions = 0
staticprotected

number of completions reported.

◆ _cond

Condition UnixAsyncStreamSocket::_cond
staticprotected

condition variable.

◆ _current

UnixStream::AsyncSocket * UnixAsyncStreamSocket::_current = nullptr
staticprotected

socket used by the resubmitting handler.

◆ _echobuf

char UnixAsyncStreamSocket::_echobuf = {}
staticprotected

buffer used by the echo server.

◆ _more

bool UnixAsyncStreamSocket::_more = false
staticprotected

last reported multishot state.

◆ _mut

Mutex UnixAsyncStreamSocket::_mut
staticprotected

condition mutex.

◆ _rearms

int UnixAsyncStreamSocket::_rearms = 0
staticprotected

number of resubmissions left to perform from the read handler.

◆ _server

UnixStream::AsyncAcceptor UnixAsyncStreamSocket::_server
protected

echo server.

◆ _serverpath

const std::string UnixAsyncStreamSocket::_serverpath = "/tmp/unixasyncserver_test.sock"
staticprotected

path.

◆ _stallpath

const std::string UnixAsyncStreamSocket::_stallpath = "/tmp/unixasyncstall_test.sock"
staticprotected

◆ _timeout

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

timeout.

◆ _transferred

size_t UnixAsyncStreamSocket::_transferred = 0
staticprotected

number of bytes reported by the last completion.


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