randolf.ca
1.00
Randolf Richardson's C++ classes
|
The rsocket multiplexer extends the functionality of the rsocket class primarily for handling multiple sockets that are beyond the scope of the single-socket-focused nature of rsocket. More...
#include <rsocket_mux>
Public Member Functions | |
rsocket_mux () noexcept | |
Instantiate an rsocket multiplexer with no rsocket objects. | |
template<class R , class... Rs> | |
rsocket_mux (const int fd_sets, R r, Rs... rs) noexcept | |
Instantiate an rsocket multiplexer with any number of rsocket objects. | |
rsocket_mux (const int fd_sets, rsocket *r) noexcept | |
Instantiate an rsocket multiplexer with one rsocket object. | |
void | erase (const int fd_sets, rsocket *r) noexcept |
Remove an rsocket object from the underlying std::set. | |
void | erase (rsocket_mux_fds rmf) |
Remove an rsocket object from the underlying std::set. | |
template<class R , class... Rs> | |
void | insert (const int fd_sets, R r, Rs... rs) |
Add one or more rsocket objects to the underlying std::set. | |
void | insert (const int fd_sets, rsocket *r) |
Add one rsocket object to the underlying std::set. | |
std::vector< rsocket_mux_fds > | poll (const int timeout=0, const bool timeout_behaviour=rsocket::TIMEOUT_EXCEPTION) |
Use the poll() method on the internal set of instantiated rsocket objects. | |
std::vector< rsocket_mux_fds > | ppoll (const struct timespec *tmo_p=nullptr, const sigset_t *sigmask=nullptr, const bool timeout_behaviour=rsocket::TIMEOUT_EXCEPTION) |
Use the ppoll() method on the internal set of instantiated rsocket objects. | |
std::vector< rsocket_mux_fds > | pselect (const struct timespec *tmo_p=nullptr, const sigset_t *sigmask=nullptr, const bool timeout_behaviour=rsocket::TIMEOUT_EXCEPTION) |
Use the pselect() method on the internal set of instantiated rsocket objects. | |
std::vector< rsocket_mux_fds > | select (struct timeval *tv=nullptr, const bool timeout_behaviour=rsocket::TIMEOUT_EXCEPTION) |
Use the select() method on the internal set of instantiated rsocket objects. | |
size_t | size () noexcept |
Find out how many rsocket entries are in this mux. | |
The rsocket multiplexer extends the functionality of the rsocket class primarily for handling multiple sockets that are beyond the scope of the single-socket-focused nature of rsocket.
Functionality of select()
, poll()
, and related socket functions are implemented within this separate rsocket_mux class partly because these specializations are beyond the scope of what the rsocket class is intended for.
|
inlinenoexcept |
|
inlinenoexcept |
Instantiate an rsocket multiplexer with one rsocket object.
The following fd_sets correspond with each respective POSIX select() fd_set, which can be combined to include the specified rsocket in multiple fd_sets:
POLLIN
= readfdsPOLLOUT
= writefdsPOLLERR
= exceptfdsfd_sets | Must be at least one of POLLIN , POLLOUT , and POLLERR |
r | Pointer to instantiated rsocket object |
|
inlinenoexcept |
Instantiate an rsocket multiplexer with any number of rsocket objects.
The following fd_sets correspond with each respective POSIX select() fd_set, which can be combined to include the specified rsocket in multiple fd_sets:
POLLIN
= readfdsPOLLOUT
= writefdsPOLLERR
= exceptfdsfd_sets | Must be at least one of POLLIN , POLLOUT , and POLLERR |
r | Pointer to instantiated rsocket object |
rs | Variadic arguments (any quantity of instantiated rsocket objects) |
|
inlinenoexcept |
Remove an rsocket object from the underlying std::set.
fd_sets | Must be at least one of POLLIN , POLLOUT , and POLLERR |
r | Pointer to instantiated rsocket object |
|
inline |
Remove an rsocket object from the underlying std::set.
rmf | Structure that is comprised of an rsocket object and its fd_set flags |
|
inline |
Add one rsocket object to the underlying std::set.
fd_sets | Must be at least one of POLLIN , POLLOUT , and POLLERR |
r | Pointer to instantiated rsocket object |
|
inline |
Add one or more rsocket objects to the underlying std::set.
fd_sets | Must be at least one of POLLIN , POLLOUT , and POLLERR |
r | Pointer to instantiated rsocket object |
rs | Variadic arguments (any quantity of instantiated rsocket objects) |
|
inline |
Use the poll() method on the internal set of instantiated rsocket objects.
randolf::rex::xEAGAIN | Failure to allocate internal system resources |
randolf::rex::xEFAULT | Address structure/memory is not in a writable part of the user address space |
randolf::rex::xEINTR | Interrupted by a signal |
randolf::rex::xENOMEM | Insufficient memory |
randolf::rex::xENOTSOCK | Underlying socket file descriptor (handle) doesn't refer to a socket |
randolf::rex::xETIMEDOUT | Timeout period elapsed (even if the TIMEOUT_BEHAVIOUR flag is not set to TIMEOUT_EXCEPTION , there is a highly improbable chance that a timeout could still occur if the data is read from any of the sockets in this rsocket_mux collection by another thread before the recv(..., MSG_PEEK) call) |
timeout | Number of milliseconds to wait |
timeout_behaviour | Timeout behaviour (see rsocket::TIMEOUT_BEHAVIOUR for details) |
|
inline |
Use the ppoll() method on the internal set of instantiated rsocket objects.
randolf::rex::xEAGAIN | Failure to allocate internal system resources |
randolf::rex::xEFAULT | Address structure/memory is not in a writable part of the user address space |
randolf::rex::xEINTR | Interrupted by a signal |
randolf::rex::xENOMEM | Insufficient memory |
randolf::rex::xENOTSOCK | Underlying socket file descriptor (handle) doesn't refer to a socket |
randolf::rex::xETIMEDOUT | Timeout period elapsed (even if the TIMEOUT_BEHAVIOUR flag is not set to TIMEOUT_EXCEPTION , there is a highly improbable chance that a timeout could still occur if the data is read from any of the sockets in this rsocket_mux collection by another thread before the recv(..., MSG_PEEK) call) |
tmo_p | Pointer to a timespec structure (will not be updated) |
sigmask | Signal mask |
timeout_behaviour | Timeout behaviour (see rsocket::TIMEOUT_BEHAVIOUR for details) |
|
inline |
Use the pselect() method on the internal set of instantiated rsocket objects.
The easier way to use this method is to only add one polling type (such as POLLIN
) to the encompassing rsocket_mux object, and then all rsocket_mux_fds records returned will only be for that polling type (and then you won't have to write additional code to confirm the polling type). However, easier doesn't necessarily equate to better, and your needs and use case(s) should normally be considered in determining which approach is the most appropriate to write code for.
randolf::rex::xEAGAIN | Failure to allocate internal system resources |
randolf::rex::xEFAULT | Address structure/memory is not in a writable part of the user address space |
randolf::rex::xEINTR | Interrupted by a signal |
randolf::rex::xENOMEM | Insufficient memory |
randolf::rex::xENOTSOCK | Underlying socket file descriptor (handle) doesn't refer to a socket |
randolf::rex::xETIMEDOUT | Timeout period elapsed (even if the TIMEOUT_BEHAVIOUR flag is not set to TIMEOUT_EXCEPTION , there is a highly improbable chance that a timeout could still occur if the data is read from any of the sockets in this rsocket_mux collection by another thread before the recv(..., MSG_PEEK) call) |
tmo_p | Pointer to a timespec structure (will not be updated) |
sigmask | Signal mask |
timeout_behaviour | Timeout behaviour (see rsocket::TIMEOUT_BEHAVIOUR for details) |
|
inline |
Use the select() method on the internal set of instantiated rsocket objects.
The easier way to use this method is to only add one polling type (such as POLLIN
) to the encompassing rsocket_mux object, and then all rsocket_mux_fds records returned will only be for that polling type (and then you won't have to write additional code to confirm the polling type). However, easier doesn't necessarily equate to better, and your needs and use case(s) should normally be considered in determining which approach is the most appropriate to write code for.
randolf::rex::xEAGAIN | Failure to allocate internal system resources |
randolf::rex::xEFAULT | Address structure/memory is not in a writable part of the user address space |
randolf::rex::xEINTR | Interrupted by a signal |
randolf::rex::xENOMEM | Insufficient memory |
randolf::rex::xENOTSOCK | Underlying socket file descriptor (handle) doesn't refer to a socket |
randolf::rex::xETIMEDOUT | Timeout period elapsed (even if the TIMEOUT_BEHAVIOUR flag is not set to TIMEOUT_EXCEPTION , there is a highly improbable chance that a timeout could still occur if the data is read from any of the sockets in this rsocket_mux collection by another thread before the recv(..., MSG_PEEK) call) |
tv | Pointer to a timeval structure (may also be updated with duration remaining if defined) |
timeout_behaviour | Timeout behaviour (see rsocket::TIMEOUT_BEHAVIOUR for details) |
|
inlinenoexcept |
Find out how many rsocket entries are in this mux.