home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 6
/
FreshFish_September1994.bin
/
gnu
/
man
/
cat2
/
select.0
< prev
next >
Wrap
Text File
|
1993-12-07
|
5KB
|
133 lines
SELECT(2) UNIX Programmer's Manual SELECT(2)
NNAAMMEE
sseelleecctt - synchronous I/O multiplexing
SSYYNNOOPPSSIISS
##iinncclluuddee <<uunniissttdd..hh>>
##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
##iinncclluuddee <<ssyyss//ttiimmee..hh>>
_i_n_t
sseelleecctt(_i_n_t _n_f_d_s, _f_d___s_e_t _*_r_e_a_d_f_d_s, _f_d___s_e_t _*_w_r_i_t_e_f_d_s, _f_d___s_e_t _*_e_x_c_e_p_t_f_d_s,
_s_t_r_u_c_t _t_i_m_e_v_a_l _*_t_i_m_e_o_u_t)
FFDD__SSEETT(_f_d, _&_f_d_s_e_t)
FFDD__CCLLRR(_f_d, _&_f_d_s_e_t)
FFDD__IISSSSEETT(_f_d, _&_f_d_s_e_t)
FFDD__ZZEERROO(_&_f_d_s_e_t)
DDEESSCCRRIIPPTTIIOONN
SSeelleecctt() 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 writing, or have an exceptional condi
tion pending, respectively. The first _n_f_d_s descriptors are checked in
each set; i.e., the descriptors from 0 through _n_f_d_s1 in the descriptor
sets are examined. On return, sseelleecctt() replaces the given descriptor
sets with subsets consisting of those descriptors that are ready for the
requested operation. SSeelleecctt() returns the total number of ready descrip
tors in all the sets.
The descriptor sets are stored as bit fields in arrays of integers. The
following macros are provided for manipulating such descriptor sets:
FFDD__ZZEERROO(_&_f_d_s_e_t_x) initializes a descriptor set _f_d_s_e_t to the null set.
FFDD__SSEETT(_f_d, _&_f_d_s_e_t) includes a particular descriptor _f_d in _f_d_s_e_t.
FFDD__CCLLRR(_f_d, _&_f_d_s_e_t) removes _f_d from _f_d_s_e_t. FFDD__IISSSSEETT(_f_d, _&_f_d_s_e_t) is non
zero 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 FD_SETSIZE, which is normally at least equal to the max
imum number of descriptors supported by the system.
If _t_i_m_e_o_u_t is a nonnil pointer, it specifies a maximum interval to wait
for the selection to complete. If _t_i_m_e_o_u_t is a nil pointer, the select
blocks indefinitely. To affect a poll, the _t_i_m_e_o_u_t argument should be
nonnil, pointing to a zerovalued 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 nil pointers if
no descriptors are of interest.
RREETTUURRNN VVAALLUUEESS
SSeelleecctt() returns the number of ready descriptors that are contained in
the descriptor sets, or 1 if an error occurred. If the time limit ex
pires, sseelleecctt() returns 0. If sseelleecctt() returns with an error, including
one due to an interrupted call, the descriptor sets will be unmodified.
EERRRROORRSS
An error return from sseelleecctt() 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.
SSEEEE AALLSSOO
accept(2), connect(2), read(2), write(2), recv(2), send(2), getdta
blesize(2)
BBUUGGSS
Although the provision of getdtablesize(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 sufficiently large bit field for select
remains a problem. The default size FD_SETSIZE (currently 256) is some
what larger than the current kernel limit to the number of open files.
However, in order to accommodate programs which might potentially 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 be
fore the inclusion of <_s_y_s_/_t_y_p_e_s_._h>.
SSeelleecctt() should probably return the time remaining from the original
timeout, if any, by modifying the time value in place. This may be im
plemented in future versions of the system. Thus, it is unwise to assume
that the timeout value will be unmodified by the sseelleecctt() call.
HHIISSTTOORRYY
The sseelleecctt function call appeared in 4.2BSD.
4.2 Berkeley Distribution March 10, 1991 2