# select.h ## **Overview** **Related Modules:** [IO](IO.md) **Description:** Provides functions and structures related to I/O multiplexing. These functions can be used to implement I/O multiplexing. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Data Structures

Data Structure Name

Description

fd_set

Defines a file descriptor set.

## Macros

Macro Name and Value

Description

FD_SETSIZE   1024

Defines the size of fd_set, that is, the maximum number of monitored files.

FD_ZERO(s)   do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0)

Clears all elements in the file descriptor set.

FD_SET(d, s)   ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))

Adds a file descriptor to a set.

FD_CLR(d, s)   ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))

Removes a file descriptor from a set.

FD_ISSET(d, s)   !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))

Checks whether a file descriptor is in a set.

## Typedefs

Typedef Name

Description

fd_mask

typedef unsigned long 

Defines fd_set as the alias of the element type.

## Functions

Function Name

Description

select (int nfds, fd_set *__restrict readfds, fd_set *__restrict writefds, fd_set *__restrict exceptfds, struct timeval *__restrict timeout)

int 

Monitors the I/O events of multiple file descriptors.