randolf.ca  1.00
Randolf's C++ classes
randolf::rsocket_group Class Reference

An rsocket_group provides a means to associate multiple rsocket objects so that the same operation can be performed on all of them at once. More...

+ Collaboration diagram for randolf::rsocket_group:

Public Member Functions

 rsocket_group () noexcept
 Instantiate an rsocket group with no rsocket objects. More...
 
template<class R , class... Rs>
 rsocket_group (R r, Rs... rs) noexcept
 Instantiate an rsocket group with any number of rsocket objects. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > close ()
 Close all rsocketss that are in this rsocket_group. More...
 
void erase (rsocket *r)
 Remove an rsocket object from the underlying std::set. More...
 
template<class R , class... Rs>
void insert (R r, Rs... rs)
 Add one or more rsocket objects to the underlying std::set. More...
 
void insert (rsocket *r)
 Add one rsocket object to the underlying std::set. More...
 
std::string name () noexcept
 Find out what this rsocket_group's name is. More...
 
void name (const std::string name) noexcept
 Specify a name for this rsocket_group. More...
 
std::shared_ptr< rsocket_ionet_io () noexcept
 Get the combined total of socket I/O statistics from all rsocket objects in this group. More...
 
std::string net_io (const char *format, size_t len=0) noexcept
 Get combined total of socket I/O statistics from all rsocket objects in this group as a pre-formatted std::string object. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send (const char *msg, const size_t len, const int flags=0)
 Send data in the form of a C-string to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send (const std::string msg, const int flags=0)
 Send data in the form of a std::string to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send (const std::vector< char > msg, const int flags=0)
 Send data in the form of a std::vector<char> to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_asciiz (const char *msg, const int flags=0)
 Send data in the form of an ASCIIZ string to all rsocket endpoints that are in this rsocket_group., including the terminating NULL character. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_byte (const char value, const int flags=0)
 Send one byte of data to all rsocket endpoints that are in this rsocket_group. More...
 
template<typename T >
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_eol (const int flags=0)
 Send the EoL sequence to all rsocket endpoints that are in this rsocket_group. More...
 
template<typename T >
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_struct (const T value, const int flags=0)
 Send one byte of data to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_uint16_lsb (const uint16_t value, const int flags=0)
 Send one 16-bit unsigned integer of data in LSB (little endian) order to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_uint16_msb (const uint16_t value, const int flags=0)
 Send one 16-bit integer of data in MSB (big endian) order to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_uint32_lsb (const uint32_t value, const int flags=0)
 Send one 32-bit unsigned integer of data in LSB (little endian) order to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_uint32_msb (const uint32_t value, const int flags=0)
 Send one 32-bit unsigned integer of data in MSB (big endian) order to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_uint64_lsb (const uint64_t value, const int flags=0)
 Send one 64-bit unsigned integer of data in LSB (little endian) order to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > send_uint64_msb (const uint64_t value, const int flags=0)
 Send one 64-bit unsigned integer of data in MSB (big endian) order to all rsocket endpoints that are in this rsocket_group. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > sendline (const std::string msg=std::string(), const int flags=0)
 Send data in the form of a std::string to all rsocket endpoints that are in this rsocket_group, with an EoL sequence appended. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > sendz (const char *msg, const int flags=0)
 Send data in the form of an ASCIIZ string to all rsocket endpoints that are in this rsocket_group.. The terminating NULL character won't be transmitted. More...
 
std::pair< std::vector< rsocket_group_rc >, std::vector< rsocket_group_rc > > shutdown (const int how=SHUT_RDWR)
 Shut down the underlying sockets in all rsocket objects that are in this rsocket_group, partially or fully. More...
 
size_t size ()
 Find out how many rsocket entries are in this group. More...
 

Detailed Description

An rsocket_group provides a means to associate multiple rsocket objects so that the same operation can be performed on all of them at once.

The rsocket::accept() and rsocket::accept4() methods can also be configured to automatically assign group membership to new connections, which can be particularly useful for certain types of multi-user systems.

Threads
This class is threadsafe.
Author
Randolf Richardson
Version
1.00
History
2022-Dec-29 v1.00 Initial version

Constructor & Destructor Documentation

◆ rsocket_group() [1/2]

randolf::rsocket_group::rsocket_group ( )
inlinenoexcept

Instantiate an rsocket group with no rsocket objects.

See also
insert()

◆ rsocket_group() [2/2]

template<class R , class... Rs>
randolf::rsocket_group::rsocket_group ( r,
Rs...  rs 
)
inlinenoexcept

Instantiate an rsocket group with any number of rsocket objects.

See also
insert()
Parameters
rPointer to instantiated rsocket object
rsVariadic arguments (any quantity of instantiated rsocket objects)

Member Function Documentation

◆ close()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::close ( )
inline

Close all rsocketss that are in this rsocket_group.

Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::close()

◆ erase()

void randolf::rsocket_group::erase ( rsocket r)
inline

Remove an rsocket object from the underlying std::set.

Threads
This method is threadsafe.
Parameters
rPointer to instantiated rsocket object

◆ insert() [1/2]

void randolf::rsocket_group::insert ( rsocket r)
inline

Add one rsocket object to the underlying std::set.

Threads
This method is threadsafe.
Parameters
rPointer to instantiated rsocket object

◆ insert() [2/2]

template<class R , class... Rs>
void randolf::rsocket_group::insert ( r,
Rs...  rs 
)
inline

Add one or more rsocket objects to the underlying std::set.

Threads
This method is threadsafe.
Parameters
rPointer to instantiated rsocket object
rsVariadic arguments (any quantity of instantiated rsocket objects)

◆ name() [1/2]

void randolf::rsocket_group::name ( const std::string  name)
inlinenoexcept

Specify a name for this rsocket_group.

This is an arbitrary name that is entirely optional, and should be regarded as similar to the naming of threads.

Threads
This method is threadsafe.
Parameters
nameName to assign to this rsocket_group

◆ name() [2/2]

std::string randolf::rsocket_group::name ( )
inlinenoexcept

Find out what this rsocket_group's name is.

Threads
This method is threadsafe.
Returns
The name of this rsocket (or an empty std::string if this rsocket doesn't have a name)

◆ net_io() [1/2]

std::shared_ptr<rsocket_io> randolf::rsocket_group::net_io ( )
inlinenoexcept

Get the combined total of socket I/O statistics from all rsocket objects in this group.

The number of bytes transmitted and received is tracked internally, so that the information can be used later in logging. These statistics are available at all times, but for logging purposes it makes the most sense to copy this information after the rsocket is closed, at which time the final statistics will continue to be available until the rsocket's destructor takes over.

Threads
This method is threadsafe.
Returns
rsocket_io wrapped in a std::shared_ptr object to help ease memory management efforts
See also
rsocket::net_io()

◆ net_io() [2/2]

std::string randolf::rsocket_group::net_io ( const char *  format,
size_t  len = 0 
)
inlinenoexcept

Get combined total of socket I/O statistics from all rsocket objects in this group as a pre-formatted std::string object.

See the rsocket::net_io method for full documentation.

Threads
This method is threadsafe.
Returns
An interpolated format string as an std::string object.
See also
rsocket::net_io(const char*, size_t len)
Parameters
formatFormat string
lenLength of format string (in bytes), or 0 to auto-detect length if format string is an ASCIIZ string

◆ send() [1/3]

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send ( const std::string  msg,
const int  flags = 0 
)
inline

Send data in the form of a std::string to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send(const std::string, const int)
Parameters
msgData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send() [2/3]

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send ( const std::vector< char >  msg,
const int  flags = 0 
)
inline

Send data in the form of a std::vector<char> to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send(const std::vector<char>, const int)
Parameters
msgData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send() [3/3]

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send ( const char *  msg,
const size_t  len,
const int  flags = 0 
)
inline

Send data in the form of a C-string to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send(const char*, const size_t, const int)
Parameters
msgPointer to data to send
lenNumber of bytes to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_asciiz()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_asciiz ( const char *  msg,
const int  flags = 0 
)
inline

Send data in the form of an ASCIIZ string to all rsocket endpoints that are in this rsocket_group., including the terminating NULL character.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
sendz(const char*, const int) which doesn't transmit the terminating NULL character
rsocket::send_asciiz(const char*, const int)
Parameters
msgPointer to data to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_byte()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_byte ( const char  value,
const int  flags = 0 
)
inline

Send one byte of data to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send_byte(const char, const int)
Parameters
valueData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_eol()

template<typename T >
std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_eol ( const int  flags = 0)
inline

Send the EoL sequence to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
The same rsocket object so as to facilitate stacking
Parameters
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_struct()

template<typename T >
std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_struct ( const T  value,
const int  flags = 0 
)
inline

Send one byte of data to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send_struct(const T, const int)
Parameters
valueData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_uint16_lsb()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_uint16_lsb ( const uint16_t  value,
const int  flags = 0 
)
inline

Send one 16-bit unsigned integer of data in LSB (little endian) order to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send_uint16_lsb(const uint16_t, const int)
Parameters
valueData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_uint16_msb()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_uint16_msb ( const uint16_t  value,
const int  flags = 0 
)
inline

Send one 16-bit integer of data in MSB (big endian) order to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send_uint16_msb(const uint16_t, const int)
Parameters
valueData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_uint32_lsb()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_uint32_lsb ( const uint32_t  value,
const int  flags = 0 
)
inline

Send one 32-bit unsigned integer of data in LSB (little endian) order to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send_uint32_lsb(const uint32_t, const int)
Parameters
valueData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_uint32_msb()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_uint32_msb ( const uint32_t  value,
const int  flags = 0 
)
inline

Send one 32-bit unsigned integer of data in MSB (big endian) order to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send_uint32_msb(const uint32_t, const int)
Parameters
valueData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_uint64_lsb()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_uint64_lsb ( const uint64_t  value,
const int  flags = 0 
)
inline

Send one 64-bit unsigned integer of data in LSB (little endian) order to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send_uint64_lsb(const uint64_t, const int)
Parameters
valueData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ send_uint64_msb()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::send_uint64_msb ( const uint64_t  value,
const int  flags = 0 
)
inline

Send one 64-bit unsigned integer of data in MSB (big endian) order to all rsocket endpoints that are in this rsocket_group.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::send_uint64_msb(const uint64_t, const int)
Parameters
valueData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ sendline()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::sendline ( const std::string  msg = std::string(),
const int  flags = 0 
)
inline

Send data in the form of a std::string to all rsocket endpoints that are in this rsocket_group, with an EoL sequence appended.

Returns
The same rsocket object so as to facilitate stacking
Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
recvline(const size_t, const int)
rsocket::sendline(const std::string, const int)
Parameters
msgData to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ sendz()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::sendz ( const char *  msg,
const int  flags = 0 
)
inline

Send data in the form of an ASCIIZ string to all rsocket endpoints that are in this rsocket_group.. The terminating NULL character won't be transmitted.

Threads
This method is threadsafe.
Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
send_asciiz which also transmits the terminating NULL character
rsocket::sendz(const char*, const int)
Parameters
msgPointer to data to send
flagsMSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_NOSIGNAL
MSG_OOB

◆ shutdown()

std::pair<std::vector<rsocket_group_rc>, std::vector<rsocket_group_rc> > randolf::rsocket_group::shutdown ( const int  how = SHUT_RDWR)
inline

Shut down the underlying sockets in all rsocket objects that are in this rsocket_group, partially or fully.

SHUT_RD: Further receives will be disallowed SHUT_WR: Further sends will be disallowed (this may cause actions specific to the protocol family of the socket to occur) SHUT_RDWR: Further sends and receives will be disallowed (default)

Returns
A std::pair of std::vector<rsocket_group_rc> vectors, the first one containing successful operations that also record the number of bytes that were transmitted, and the second one containing failed operations that also record the exception that was thrown (see the rsocket_group_rc structure for details)
See also
rsocket::shutdown(const int)
Parameters
howSHUT_RD
SHUT_RW
SHUT_RDWR

◆ size()

size_t randolf::rsocket_group::size ( )
inline

Find out how many rsocket entries are in this group.

Threads
This method is threadsafe.
Returns
Number of rsocket objects in the underlying std::set

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