Class used to test the unix asynchronous stream socket API.
More...
|
| void | SetUp () override |
| | Sets up the test fixture.
|
| |
| void | TearDown () override |
| | Tears down the test fixture.
|
| |
|
| static Tcp::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 (Tcp::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 | onRead (const std::error_code &ec, const char *data, size_t size, bool more) |
| | handler resubmitting a read 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 | onReportWait (const std::error_code &ec, bool more) |
| | report a wait completion to the test thread.
|
| |
|
| Tcp::AsyncAcceptor | _server |
| | echo server.
|
| |
|
| 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 Tcp::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 IpAddress | _host = "::1" |
| | host.
|
| |
| static const IpAddress | _blackhole = "192.0.2.1" |
| | unreachable host keeping a connection attempt pending.
|
| |
| static const uint16_t | _port = 5034 |
| | port.
|
| |
| static const uint16_t | _stallport = 5035 |
| |
| static const std::chrono::milliseconds | _timeout {1000} |
| | timeout.
|
| |
Class used to test the unix asynchronous stream socket API.
◆ onConnect()
| static void TcpAsyncSocket::onConnect |
( |
const std::error_code & | ec | ) |
|
|
inlinestaticprotected |
handler retrying the connection from within itself.
- Parameters
-
| ec | error reported by the socket. |
◆ onEchoAccept()
| static void TcpAsyncSocket::onEchoAccept |
( |
Tcp::Socket && | sock, |
|
|
const std::error_code & | ec, |
|
|
bool | more ) |
|
inlinestaticprotected |
adopt the socket accepted by the echo server.
- Parameters
-
| sock | accepted socket. |
| ec | error reported by the acceptor. |
| more | true if the acceptation stays armed. |
◆ onEchoRead()
| static void TcpAsyncSocket::onEchoRead |
( |
const std::error_code & | ec, |
|
|
const char * | data, |
|
|
size_t | size, |
|
|
bool | more ) |
|
inlinestaticprotected |
receive the data to send back.
- Parameters
-
| ec | error reported by the socket. |
| data | buffer holding the data received. |
| size | number of bytes read. |
| more | true if the read stays armed. |
◆ onEchoWrite()
| static void TcpAsyncSocket::onEchoWrite |
( |
const std::error_code & | ec, |
|
|
size_t | size ) |
|
inlinestaticprotected |
send back the data received by the echo server.
- Parameters
-
| ec | error reported by the socket. |
| size | number of bytes written. |
◆ onRead()
| static void TcpAsyncSocket::onRead |
( |
const std::error_code & | ec, |
|
|
const char * | data, |
|
|
size_t | size, |
|
|
bool | more ) |
|
inlinestaticprotected |
handler resubmitting a read from within itself.
- Parameters
-
| ec | error reported by the socket. |
| data | buffer holding the data received. |
| size | number of bytes read. |
| more | true if the read stays armed. |
◆ onReportMulti()
| static void TcpAsyncSocket::onReportMulti |
( |
const std::error_code & | ec, |
|
|
const char * | data, |
|
|
size_t | size, |
|
|
bool | more ) |
|
inlinestaticprotected |
report a multishot completion to the test thread.
- Parameters
-
| ec | error reported by the socket. |
| data | buffer holding the data received. |
| size | number of bytes read. |
| more | true if the read stays armed. |
◆ onReportWait()
| static void TcpAsyncSocket::onReportWait |
( |
const std::error_code & | ec, |
|
|
bool | more ) |
|
inlinestaticprotected |
report a wait completion to the test thread.
- Parameters
-
| ec | error reported by the socket. |
| more | true if the wait stays armed. |
◆ onWrite()
| static void TcpAsyncSocket::onWrite |
( |
const std::error_code & | ec, |
|
|
size_t | size ) |
|
inlinestaticprotected |
handler resubmitting a write from within itself.
- Parameters
-
| ec | error reported by the socket. |
| size | number of bytes written. |
◆ peer()
| static Tcp::AsyncSocket & TcpAsyncSocket::peer |
( |
| ) |
|
|
inlinestaticprotected |
get the socket accepted by the echo server.
- Returns
- the socket accepted by the echo server.
◆ SetUp()
| void TcpAsyncSocket::SetUp |
( |
| ) |
|
|
inlineoverrideprotected |
Sets up the test fixture.
◆ TearDown()
| void TcpAsyncSocket::TearDown |
( |
| ) |
|
|
inlineoverrideprotected |
Tears down the test fixture.
◆ _blackhole
| const IpAddress TcpAsyncSocket::_blackhole = "192.0.2.1" |
|
staticprotected |
unreachable host keeping a connection attempt pending.
◆ _buf
| char TcpAsyncSocket::_buf = {} |
|
staticprotected |
◆ _code
| std::error_code TcpAsyncSocket::_code |
|
staticprotected |
◆ _completions
| int TcpAsyncSocket::_completions = 0 |
|
staticprotected |
number of completions reported.
◆ _cond
◆ _current
| Tcp::AsyncSocket * TcpAsyncSocket::_current = nullptr |
|
staticprotected |
socket used by the resubmitting handler.
◆ _echobuf
| char TcpAsyncSocket::_echobuf = {} |
|
staticprotected |
buffer used by the echo server.
◆ _host
| const IpAddress TcpAsyncSocket::_host = "::1" |
|
staticprotected |
◆ _more
| bool TcpAsyncSocket::_more = false |
|
staticprotected |
last reported multishot state.
◆ _mut
| Mutex TcpAsyncSocket::_mut |
|
staticprotected |
◆ _port
| const uint16_t TcpAsyncSocket::_port = 5034 |
|
staticprotected |
◆ _rearms
| int TcpAsyncSocket::_rearms = 0 |
|
staticprotected |
number of resubmissions left to perform from the read handler.
◆ _server
| Tcp::AsyncAcceptor TcpAsyncSocket::_server |
|
protected |
◆ _stallport
| const uint16_t TcpAsyncSocket::_stallport = 5035 |
|
staticprotected |
◆ _timeout
| const std::chrono::milliseconds TcpAsyncSocket::_timeout {1000} |
|
staticprotected |
◆ _transferred
| size_t TcpAsyncSocket::_transferred = 0 |
|
staticprotected |
number of bytes reported by the last completion.
The documentation for this class was generated from the following file: