Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ select(3C) — Dell System V Release 4 Issue 2.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

poll(2)

read(2)

write(2)



select(3C)                       UNIX System V                       select(3C)


NAME
      select - synchronous I/O multiplexing

SYNOPSIS
      #include <sys/time.h>
      #include <sys/types.h>

      select(int nfds, fdset *readfds, *writefds, *execptfds, struct
          timeval *timeout);
      FDSET(int fd, fdset fdset);
      FDCLR(int fd, fdset fdset);
      FDISSET(int fd, fdset fdset);
      FDZERO(fdset fdset);

DESCRIPTION
      select examines the I/O descriptor sets whose addresses are passed in
      readfds, writefds, and execptfds to see if any of their descriptors are
      ready for reading, are ready for writing, or have an exceptional
      condition pending, respectively.  nfds is the number of bits to be
      checked in each bit mask that represents a file descriptor; the
      descriptors from 0 to -1 in the descriptor sets are examined.  On return,
      select replaces the given descriptor sets with subsets consisting of
      those descriptors that are ready for the requested operation.  The return
      value from the call to select() is the number of ready descriptors.

      The descriptor sets are stored as bit fields in arrays of integers.  The
      following macros are provided for manipulating such descriptor sets:
      FDZERO(&fdset) initializes a descriptor set fdset to the null set.
      FDSET(fd, &fdset) includes a particular descriptor fd in fdset.
      FDCLR(fd, &fdset) removes fd from fdset.  FDISSET(fd, &fdset) is
      nonzero if fd is a member of fdset, zero otherwise.  The behavior of
      these macros is undefined if a descriptor value is less than zero or
      greater than or equal to FDSETSIZE.  FDSETSIZE is a constant defined in
      sys/select.h and is normally at least equal to the maximum number of
      descriptors supported by the system.

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

      Any of readfds, writefds, and execptfds may be given as NULL pointers if
      no descriptors are of interest.

RETURN VALUE
      select returns the number of ready descriptors contained in the
      descriptor sets or -1 if an error occurred.  If the time limit expires,
      then select returns 0.

ERRORS
      An error return from select indicates:



10/89                                                                    Page 1







select(3C)                       UNIX System V                       select(3C)


      EBADF          One of the I/O descriptor sets specified an invalid I/O
                     descriptor.

      EINTR          A signal was delivered before any of the selected events
                     occurred, or the time limit expired.

      EINVAL         A component of the pointed-to time limit is outside the
                     acceptable range:  tsec must be between 0 and 10^8,
                     inclusive. tusec must be greater-than or equal to 0, and
                     less than 10^6.

SEE ALSO
      poll(2), read(2), write(2)

NOTES
      The default value for FDSETSIZE (currently 1024) is larger than the
      default limit on the number of open files.  In order to accommodate
      programs that may 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 FDSETSIZE before the inclusion of <sys/types.h>.

      In future versions of the system, select may return the time remaining
      from the original timeout, if any, by modifying the time value in place.
      It is thus unwise to assume that the timeout value will be unmodified by
      the select call.

      The descriptor sets are always modified on return, even if the call
      returns as the result of a timeout.


























Page 2                                                                    10/89





Typewritten Software • bear@typewritten.org • Edmonds, WA 98026