randolf.ca  1.00
Randolf Richardson's C++ classes
Loading...
Searching...
No Matches
randolf::rsocket_io Struct Reference

Structure of socket I/O statistics tracked by rsocket. The reason this is a subclass of std::mutex is to ensure a thread-safe operation for the rsocket::~rsocket destructor when making a final copy of the internally-tracked I/O statistics using the pointer to this structure (if specified with the rsocket::net_io_final() method). More...

#include <rsocket_io>

+ Inheritance diagram for randolf::rsocket_io:
+ Collaboration diagram for randolf::rsocket_io:

Public Attributes

__uint128_t bytes_rx
 Total number of unencrypted bytes received.
 
__uint128_t bytes_sx
 Total number of unencrypted bytes spared (received, and remains in buffer).
 
__uint128_t bytes_tx
 Total number of unencrypted bytes transmitted.
 
__uint128_t crypt_rx
 Total number of encrypted bytes received.
 
__uint128_t crypt_sx
 Total number of encrypted bytes spared (received, and remains in buffer).
 
__uint128_t crypt_tx
 Total number of encrypted bytes transmitted.
 
bool is_final
 Should always be initialized to FALSE; reserved for the rsocket::~rsocket destructor to set to TRUE.
 

Detailed Description

Structure of socket I/O statistics tracked by rsocket. The reason this is a subclass of std::mutex is to ensure a thread-safe operation for the rsocket::~rsocket destructor when making a final copy of the internally-tracked I/O statistics using the pointer to this structure (if specified with the rsocket::net_io_final() method).

Note
To find out the total overall bytes received/transmitted, the sum of bytes_rx and crypt_rx , and the sum of bytes_tx and crypt_tx will provide this statistical information:
#include <randolf/rsocket>
std::shared_ptr<randolf::rsocket_io> io = r.net_io();
__uint128_t total_rx = io->bytes_rx // Bytes received (unencrypted)
+ io->crypt_rx; // Bytes received (encrypted)
__uint128_t total_tx = io->bytes_tx // Bytes transmitted (unencrypted)
+ io->crypt_tx; // Bytes transmitted (encrypted)
When data is buffered (buffering is triggered by the rsocket::recvline() method), there may be occasions where data is spared (left behind), which is tracked in the bytes_sx and crypt_sx values. These values can be subtracted from the totals, if need be, as follows:
#include <randolf/rsocket>
std::shared_ptr<randolf::rsocket_io> io = r.net_io();
__uint128_t total_rx = io->bytes_rx // Bytes received (unencrypted)
- io->bytes_sx // Bytes received (unencrypted spare)
+ io->crypt_rx // Bytes received (encrypted)
- io->bytes_sx; // Bytes received (encrypted spare)
__uint128_t total_tx = io->bytes_tx // Bytes transmitted (unencrypted)
+ io->crypt_tx; // Bytes transmitted (encrypted)
Spare bytes are only applicable to received data statistics because buffering is only used to receive data.

This statistical data is typically used in logging, and also in applications that keep track of I/O on a per-user basis.

See also
rsocket::net_io()
rsocket::net_io(const char*, size_t, rsocket_io*)
rsocket::net_io_final()
rsocket::net_io_update()

Member Data Documentation

◆ bytes_rx

__uint128_t randolf::rsocket_io::bytes_rx

Total number of unencrypted bytes received.

◆ bytes_sx

__uint128_t randolf::rsocket_io::bytes_sx

Total number of unencrypted bytes spared (received, and remains in buffer).

◆ bytes_tx

__uint128_t randolf::rsocket_io::bytes_tx

Total number of unencrypted bytes transmitted.

◆ crypt_rx

__uint128_t randolf::rsocket_io::crypt_rx

Total number of encrypted bytes received.

◆ crypt_sx

__uint128_t randolf::rsocket_io::crypt_sx

Total number of encrypted bytes spared (received, and remains in buffer).

◆ crypt_tx

__uint128_t randolf::rsocket_io::crypt_tx

Total number of encrypted bytes transmitted.

◆ is_final

bool randolf::rsocket_io::is_final

Should always be initialized to FALSE; reserved for the rsocket::~rsocket destructor to set to TRUE.

See also
rsocket::~rsocket()

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