randolf.ca  1.00
Randolf's C++ classes
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...

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

Public Attributes

ulong bytes_rx
 Total number of unencrypted bytes received. More...
 
ulong bytes_sx
 Total number of unencrypted bytes spared (received, but left in buffer) More...
 
ulong bytes_tx
 Total number of unencrypted bytes transmitted. More...
 
ulong crypt_rx
 Total number of encrypted bytes received. More...
 
ulong crypt_sx
 Total number of encrypted bytes spared (received, but left in buffer) More...
 
ulong crypt_tx
 Total number of encrypted bytes transmitted. More...
 
bool is_final
 Should always be initialized to FALSE; reserved by ~rsocket to set to TRUE. More...
 

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();
ulong total_rx = io->bytes_rx // Bytes received (unencrypted)
+ io->crypt_rx; // Bytes received (encrypted)
ulong 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();
ulong 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)
ulong 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

ulong randolf::rsocket_io::bytes_rx

Total number of unencrypted bytes received.

◆ bytes_sx

ulong randolf::rsocket_io::bytes_sx

Total number of unencrypted bytes spared (received, but left in buffer)

◆ bytes_tx

ulong randolf::rsocket_io::bytes_tx

Total number of unencrypted bytes transmitted.

◆ crypt_rx

ulong randolf::rsocket_io::crypt_rx

Total number of encrypted bytes received.

◆ crypt_sx

ulong randolf::rsocket_io::crypt_sx

Total number of encrypted bytes spared (received, but left in buffer)

◆ crypt_tx

ulong 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 by ~rsocket to set to TRUE.


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