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 <randolf/rsocket_io>

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

Public Attributes

__uint128_t bytes_hx
 Quantity of unencrypted bytes harvested (received).
__uint128_t bytes_rx
 Quantity of unencrypted bytes received.
__uint128_t bytes_sx
 Quantity of unencrypted bytes spared (received, and remains in buffer).
__uint128_t bytes_tx
 Quantity of unencrypted bytes transmitted.
__uint128_t crypt_hx
 Quantity of encrypted bytes harvested (received).
__uint128_t crypt_rx
 Quantity of encrypted bytes received.
__uint128_t crypt_sx
 Quantity of encrypted bytes spared (received, and remains in buffer).
__uint128_t crypt_tx
 Quantity 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, the sum of bytes_sx and crypt_sx, and the sum of bytes_tx and crypt_tx will provide this statistical information:
#include <randolf/rsocket>
std::unique_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_sx = io->bytes_sx // Spare bytes received (unencrypted)
+ io->crypt_sx; // Spare bytes received (encrypted)
__uint128_t total_hx = io->bytes_hx // Harvested bytes received (unencrypted)
+ io->crypt_hx; // Harvested 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::unique_ptr<randolf::rsocket_io> io = r.net_io();
__uint128_t total_rx = io->bytes_rx // Bytes received (unencrypted)
+ io->crypt_rx // Bytes received (encrypted)
- io->bytes_sx // Bytes received (unencrypted spare)
- io->crypt_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.

Author
Randolf Richardson
Version
1.00
History
  • 2023-Apr-30 v1.00 Initial version
  • 2025-Aug-30 v1.00 Added tracking of rsocket::harvested() bytes received
See also
rsocket::harvest()
rsocket::harvested()
rsocket::net_io()
rsocket::net_io(const char*, int, rsocket_io*)
rsocket::net_io_final()
rsocket::net_io_update()

Member Data Documentation

◆ bytes_rx

__uint128_t randolf::rsocket_io::bytes_rx

Quantity of unencrypted bytes received.

Referenced by randolf::rsocket::net_io().

◆ bytes_sx

__uint128_t randolf::rsocket_io::bytes_sx

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

Referenced by randolf::rsocket::net_io().

◆ bytes_hx

__uint128_t randolf::rsocket_io::bytes_hx

Quantity of unencrypted bytes harvested (received).

Referenced by randolf::rsocket::net_io().

◆ bytes_tx

__uint128_t randolf::rsocket_io::bytes_tx

Quantity of unencrypted bytes transmitted.

Referenced by randolf::rsocket::net_io().

◆ crypt_rx

__uint128_t randolf::rsocket_io::crypt_rx

Quantity of encrypted bytes received.

Referenced by randolf::rsocket::net_io().

◆ crypt_sx

__uint128_t randolf::rsocket_io::crypt_sx

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

Referenced by randolf::rsocket::net_io().

◆ crypt_hx

__uint128_t randolf::rsocket_io::crypt_hx

Quantity of encrypted bytes harvested (received).

Referenced by randolf::rsocket::net_io().

◆ crypt_tx

__uint128_t randolf::rsocket_io::crypt_tx

Quantity of encrypted bytes transmitted.

Referenced by randolf::rsocket::net_io().

◆ 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:
  • randolf/rsocket_io