io_multiplexer


Network<ToolKit> includes the class os_io_multiplexer to manage multiple socket connections. This class waits for the following interesting conditions.

An os_io_multiplexer contains a set of descriptors that are considered for each kind of condition. To set or access the descriptors that are scanned for read, write, and exception conditions, use read_scan() , write_scan() , and exception_scan() .

When you execute select() with an optional time-out parameter, this function blocks the process until at least one interesting condition is detected or a time-out occurs. Then this function returns the number of descriptors that have a pending condition. To determine which descriptors are associated with the detected conditions, use readable() , writable() , and exceptional() .

Library

Network<ToolKit>

Declaration

#include <ospace/network/iomux.h>

class os_io_multiplexer

Enums

enum os_io_multiplexer::event_t
  {
  read_event,
  write_event,
  except_event
  };
  

Interface

Constructor
os_io_multiplexer()
Constructs an I/O multiplexer with no associated descriptors.
==
bool operator==( const os_io_multiplexer& io_multiplexer ) const
Returns true if read, write, and exception vectors are the same as io_multiplexer .
add_scan
void add_scan( os_sock_t descriptor , event_t event )
Adds  descriptor to the list of descriptors scanned for event .
exception_scan
void exception_scan( const vector< os_sock_t >& descriptors )
Sets the descriptors that should be considered for pending exceptions to descriptors .
exception_scan
const vector< os_sock_t > exception_scan() const
Returns the vector of descriptors that are scanned for pending exception conditions.
exceptional
vector< os_sock_t > exceptional() const
Returns the vector of descriptors that have pending exception conditions.
print
void print( ostream& stream ) const
Prints the object to stream .
read_scan
const vector< os_sock_t > read_scan() const
Returns the vector of descriptors that are scanned for read-readiness.
read_scan
void read_scan( const vector< os_sock_t >& descriptors )
Sets the descriptors that should be scanned for read-readiness to descriptors .
readable
vector< os_sock_t > readable() const
Returns the vector of descriptors that are ready to read.
ready
void ready( const vector< os_sock_t >& descriptors , event_t event )
Sets the vector of descriptors that are ready on event .
remove_scan
void remove_scan( os_sock_t descriptor , event_t event )
Removes  descriptor from the list of descriptors scanned for event .
scan
const vector< os_sock_t > scan( event_t event ) const
Returns the vector of descriptors that are scanned for event-readiness.
scan
void scan( const vector< os_sock_t >& descriptors , event_t event )
Sets the descriptors that should be scanned for event-readiness to descriptors .
select
int select( timeval* time_out )
If the time_out (default 0 ) is 0 , then blocks until at least one descriptor has a pending action,  or if the time_out is not 0 , then blocks until at least one descriptor has a pending action or until time_out passes. Returns the number of descriptors that are ready for an action. Returns 0 on timeout.

Throws: os_network_toolkit_error

select
int select( long seconds , long microseconds )
Blocks until at least one descriptor has a pending action or until seconds + microseconds (default 0 ) passes. Returns the number of descriptors that are ready for an action. Returns 0 on timeout.

Throws: os_network_toolkit_error

write_scan
const vector< os_sock_t > write_scan() const
Returns the vector of descriptors that are scanned for write-readiness.
write_scan
void write_scan( const vector< os_sock_t >& descriptors )
Sets descriptors that are scanned for write-readiness to descriptors .
writable
vector< os_sock_t > writable() const
Returns the vector of descriptors that are ready to write.

Non-Member Functions

<<
ostream& operator<<( ostream& stream , const os_io_multiplexer& mux )
Prints mux to stream .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.