Socket I/O multiplexer.
More...
#include <base/net/MultipleSockets.h>
Inherits Object.
Socket I/O multiplexer.
Socket I/O multiplexer.
- Version
- 1.0
◆ anonymous enum
Events.
Enumerator |
---|
INPUT | Normal data may be read without blocking.
|
PRIORITY_INPUT | Priority data may be read without blocking.
|
HIGH_PRIORITY_INPUT | High priority data may be read without blocking.
|
OUTPUT | Data may be written without blocking.
|
PRIORITY_OUTPUT | Priority data may be written without blocking.
|
ERROR | Error condition.
|
DISCONNECTED | The connection has been disconnected.
|
◆ MultipleSockets()
MultipleSockets::MultipleSockets |
( |
| ) |
|
Initializes multiple socket object.
◆ ~MultipleSockets()
MultipleSockets::~MultipleSockets |
( |
| ) |
|
|
noexcept |
◆ add()
Adds a socket with the specified events filter (only INPUT, PRIORITY_INPUT, HIGH_PRIORITY_INPUT, OUTPUT, and PRIORITY_OUTPUT are significant).
- Parameters
-
socket | The socket to be added. |
events | The filter events. The default is all events. |
◆ getEvents()
unsigned int MultipleSockets::getEvents |
( |
StreamSocket |
socket | ) |
|
Returns the events for the specified socket. Raises InvalidKey if socket is invalid. The socket is deselected if present within the selected socket set.
◆ getFilter()
unsigned int MultipleSockets::getFilter |
( |
StreamSocket |
socket | ) |
const |
Returns the currently filtered events (mask of INPUT, PRIORITY_INPUT, HIGH_PRIORITY_INPUT, OUTPUT, and PRIORITY_OUTPUT).
◆ getSelected()
unsigned int MultipleSockets::getSelected |
( |
| ) |
const |
|
inlinenoexcept |
Returns the current number of selected sockets.
◆ poll() [1/2]
unsigned int MultipleSockets::poll |
( |
| ) |
|
Waits for an event on one of the sockets.
- Returns
- The number of sockets which have changed.
◆ poll() [2/2]
unsigned int MultipleSockets::poll |
( |
unsigned int |
milliseconds | ) |
|
Waits for an event on one of the sockets. The time out period is silently clamped to 999999999.
- Parameters
-
milliseconds | The time out period. |
- Returns
- The number of sockets which have changed. 0 if interrrupted or timed out.
◆ remove()
Removes a socket.
- Parameters
-
socket | The socket to be removed. |
◆ setFilter()
void MultipleSockets::setFilter |
( |
StreamSocket |
socket, |
|
|
unsigned int |
events |
|
) |
| |
Sets the events filter (only INPUT, PRIORITY_INPUT, HIGH_PRIORITY_INPUT, OUTPUT, and PRIORITY_OUTPUT are significant).
◆ signal()
Signals the listener for each selected socket. Resets the number of selected sockets.
◆ GRANULARITY
const unsigned int MultipleSockets::GRANULARITY = 64 |
|
static |