[0m


SELECT(2)	    UNIX Programmer's Manual		SELECT(2)



[1mNAME
     [0mselect - synchronous I/O multiplexing

[1mSYNOPSIS
     #include <sys/types.h>
     #include <sys/time.h>

     nfound = select(nfds, readfds, writefds, exceptfds, timeout)
     int nfound, nfds;
     fd_set *readfds, *writefds, *exceptfds;
     struct timeval *timeout;

     FD_SET(fd, &fdset)
     FD_CLR(fd, &fdset)
     FD_ISSET(fd, &fdset)
     FD_ZERO(&fdset)
     int fd;
     fd_set fdset;

DESCRIPTION
     [0m_S_e_l_e_c_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 some of
     their descriptors are ready for reading, are ready for writ-
     ing, or have an exceptional condition pending, respectively.
     The first _n_f_d_s descriptors are checked in each set; i.e. the
     descriptors from 0 through _n_f_d_s-1 in the descriptor sets are
     examined.	On return, _s_e_l_e_c_t replaces the given descriptor
     sets with subsets consisting of those descriptors that are
     ready for the requested operation.  The total number of
     ready descriptors in all the sets is returned in _n_f_o_u_n_d.

     The descriptor sets are stored as bit fields in arrays of
     integers.	The following macros are provided for manipulat-
     ing such descriptor sets: _F_D__Z_E_R_O(&_f_d_s_e_t) initializes a
     descriptor set _f_d_s_e_t to the null set.  _F_D__S_E_T(_f_d, &_f_d_s_e_t)
     includes a particular descriptor _f_d in _f_d_s_e_t.  _F_D__C_L_R(_f_d,
     &_f_d_s_e_t) removes _f_d from _f_d_s_e_t.  _F_D__I_S_S_E_T(_f_d, &_f_d_s_e_t) is
     nonzero if _f_d is a member of _f_d_s_e_t, zero otherwise.  The
     behavior of these macros is undefined if a descriptor value
     is less than zero or greater than or equal to _F_D__S_E_T_S_I_Z_E,
     which is normally at least equal to the maximum number of
     descriptors supported by the system.

     If _t_i_m_e_o_u_t is a non-zero pointer, it specifies a maximum
     interval to wait for the selection to complete.  If _t_i_m_e_o_u_t
     is a zero pointer, the select blocks indefinitely.  To
     affect a poll, the _t_i_m_e_o_u_t argument should be non-zero,
     pointing to a zero-valued timeval structure.

     Any of _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 may be given as zero
     pointers if no descriptors are of interest.




Printed 12/11/92    Revision 1.2 of 19/10/88			1






SELECT(2)	    UNIX Programmer's Manual		SELECT(2)



[1mRETURN VALUE
     [0m_S_e_l_e_c_t returns the number of ready descriptors that are con-
     tained in the descriptor sets, or -1 if an error occurred.
     If the time limit expires then _s_e_l_e_c_t returns 0.  If _s_e_l_e_c_t
     returns with an error, including one due to an interrupted
     call, the descriptor sets will be unmodified.

[1mERRORS
     [0mAn error return from _s_e_l_e_c_t indicates:

     [EBADF]	    One of the descriptor sets specified an
		    invalid descriptor.

     [EINTR]	    A signal was delivered before the time limit
		    expired and before any of the selected events
		    occurred.

     [EINVAL]	    The specified time limit is invalid.  One of
		    its components is negative or too large.

[1mSEE ALSO
     [0maccept(2), connect(2), read(2), write(2), recv(2), send(2),
     getdtablesize(2)

[1mBUGS
     [0mAlthough the provision of _g_e_t_d_t_a_b_l_e_s_i_z_e(2) was intended to
     allow user programs to be written independent of the kernel
     limit on the number of open files, the dimension of a suffi-
     ciently large bit field for select remains a problem.  The
     default size FD_SETSIZE (currently 256) is somewhat larger
     than the current kernel limit to the number of open files.
     However, in order to accommodate programs which might poten-
     tially use a larger number of open files with select, it is
     possible to increase this size within a program by providing
     a larger definition of FD_SETSIZE before the inclusion of
     <sys/types.h>.

     _S_e_l_e_c_t should probably return the time remaining from the
     original timeout, if any, by modifying the time value in
     place.  This may be implemented in future versions of the
     system.  Thus, it is unwise to assume that the timeout value
     will be unmodified by the _s_e_l_e_c_t call.













Printed 12/11/92    Revision 1.2 of 19/10/88			2



[0m