Metrologic Optimus S Programming Manual page 163

"c" programming guide
Table of Contents

Advertisement

select
Purpose
To synchronize I/O multiplexing.
Syntax
int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct
timeval *timeout);
domain
type
protocol
Example
(?)
Description
This routine examines the I/O descriptor sets whose addresses are passed in
readfds, writefds, and exceptfds to see if some of their descriptors are ready for
reading, are ready for writing, or have an exceptional condition pending,
respectively. The only exceptional condition detectable is out-of-band data
received on a socket.
Return
If successful, it returns the number of ready descriptors.
If the time limit expires, it returns 0.
On error, it returns -1.
The global variable errno is set to indicate the error condition encountered.
See Also
accept, connect, recv, send
Chapter 3 Terminal Specific Function Library
Protocol family; this should always be PF_INET or AF_INET.
Socket type, either SOCK_STREAM or SOCK_DGRAM.
Depending on the type parameter specified, the protocol to be
used can be TCP, UDP, or ICMP.
The first nfds descriptors are checked in each set; i.e. the descriptors from
0 through nfds -1 in the descriptor sets are examined.
On return, this routine replaces the given descriptor sets with subsets
consisting of those descriptors that are ready for the requested operation. It
returns the total number of ready descriptors in all the sets.
The descriptor sets are stored as bit fields in arrays of integers. The
following are provided for manipulating such descriptor sets. Their
behavior 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
maximum number of descriptors supported by the system.
FD_SETSIZE 8
The maximum number of descriptors is 8.
FD_SET (n, p)
((p) -> fds_bits [(n) >>3 ] |= (1 << ((n) & 7)))
FD_CLR (n, p)
((p) -> fds_bits [(n) >>3 ] &= ~(1 << ((n) & 7)))
FD_ISSET (n, p)
((p) -> fds_bits [(n) >>3 ] & (1 << ((n) & 7)))
FD_ZERO (p)
memset ((void *) (p), 0, sizeof (*(p)))
The timeout argument, pointing to a zero-valued timeval structure,
specifies the maximum interval to wait for the selection to complete.
System activity can lengthen the interval by an indeterminate amount. If it
is a null pointer, the select blocks indefinitely.
Any of readfds, writefds, and exceptfds may be given as null pointers if no
descriptors are of interest.
157

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents