sseelleecctt() -- Sockets Function (libsocket)

Synchronous I/O multiplexing
#iinncclluuddee <uunniissttdd.hh>
#iinncclluuddee <ssyyss/ttyyppeess.hh>
#iinncclluuddee <ssyyss/ttiimmee.hh>
iinntt sseelleecctt(_n_f_d_s, _r_e_a_d_f_d_s, _w_r_i_t_e_f_d_s, _e_x_c_e_p_t_f_d_s, _t_i_m_e_o_u_t)
iinntt _n_f_d_s; ffdd_sseett *_r_e_a_d_f_d_s, *_w_r_i_t_e_f_d_s, *_e_x_c_e_p_t_f_d_s; ssttrruucctt ttiimmeevvaall *_t_i_m_e_o_u_t;

Function  sseelleecctt() examines  the I/O  descriptor  sets whose  addresses are
passed  in _r_e_a_d_f_d_s  _w_r_i_t_e_f_d_s and  _e_x_c_e_p_t_f_d_s, to  see if  their descriptors,
respectively,  are ready  for reading,  are ready for  writing, or  have an
exceptional condition  pending.  It examines descriptors  zero through _n_f_d_s
in each set.  Upon return, sseelleecctt() replaces the given descriptor sets with
the  subsets of  descriptors that  are ready  for the  requested operation.
sseelleecctt()  returns the  number of  ready  descriptors in  all the  sets.  If
_r_e_a_d_f_d_s, _w_r_i_t_e_f_d_s, or _e_x_c_e_p_t_f_d_s contains no descriptor of interest, you can
set it to NULL.

The descriptor  sets are stored as  bit fields in arrays  of integers.  The
following macros are provided for manipulating such descriptor sets:

FFDD_ZZEERROO &_f_d_s_e_t
     Initialize descriptor set _f_d_s_e_t to the null set.

FFDD_SSEETT _f_d &_f_d_s_e_t
     Include descriptor ffdd within _f_d_s_e_t.

FFDD_CCLLRR _f_d &_f_d_s_e_t
     Remove _f_d from _f_d_s_e_t.

FFDD_IISSSSEETT _f_d &_f_d_s_e_t
     Evaluate to  a non-zero value if  _f_d is a member  of _f_d_s_e_t; otherwise,
     evaluate to zero.

The behavior of  these macros is undefined if a  descriptor's value is less
than zero or  greater than or equal to FFDD_SSEETTSSIIZZEE,  which normally at least
equals the maximum number of file descriptors supported by your system.

If _t_i_m_e_o_u_t is not NULL, sseelleecctt() gives the maximum interval to wait for the
selection to complete.  If it  is NULL, sseelleecctt() indefinitely.  To affect a
poll,  _t_i_m_e_o_u_t  argument should  be  not NULL,  pointing  to a  zero-valued
ttiimmeevvaall structure.

If all goes well sseelleecctt() returns  the number of ready descriptors that are
contained in  the descriptor sets.   If the time limit  expires, it returns
zero.  If  an error  occurs, it  returns -1, sets  eerrrrnnoo to  an appropriate
value, and leaves all  descriptor sets unmodified.  The following gives the
possible errors, by the value to which sseelleecctt() sets eerrrrnnoo:

EEBBAADDFF
     One of the descriptor sets specifies an invalid descriptor.

EEIINNTTRR
     A signal was delivered before the time limit expired and before any of
     the selected events occurred.

EEIINNVVAALL
     The specified time limit is invalid: one of its components is negative
     or too large.

_S_e_e _A_l_s_o
aacccceepptt(), ccoonnnneecctt(), lliibbssoocckkeett, rreeaadd(), wwrriittee()
