select-0.4.0.1: Wrap the select(2) POSIX function

Safe HaskellNone

System.Posix.IO.Select.FdSet

Description

Interface to fd_set. See select(2).

The type FdSet is opaque, but is implemented internally as a pointer to an fd_set. All operations on FdSets must adhere to the requirements of FD_CLR, FD_ISSET, FD_SET and FD_ZERO (see select(2)). This includes requiring valid file descriptors for all operations. Most functions in this module are kept in the IO monad to make it easier to guarantee validity of the file descriptors, but since invalid ones seem to work fine in practice (at least on Linux), the module System.Posix.IO.Select.FdSet.Unsafe provides a non-IO interface.

Functions that return an FdSet, such as insert, copy the underlying fd_set in order to be referentially transparent.

In the documentation that follows, a file descriptor is said to be in range if it is non-negative and strictly smaller than the system-defined FD_SETSIZE. Many functions silently ignore file descriptors that are not in range.

Synopsis

Documentation

fromList :: [Fd] -> IO FdSetSource

Create an FdSet from a list of file descriptors. File descriptors not in range (see above) are silently ignored.

insert :: Fd -> FdSet -> IO FdSetSource

Insert a file descriptor.

insertList :: [Fd] -> FdSet -> IO FdSetSource

Insert multiple file descriptors. This is more efficient than multiple inserts (only a single copy of the set is made).

empty :: IO FdSetSource

An empty FdSet.

elem :: Fd -> FdSet -> IO BoolSource

Test for membership. Recall that POSIX allows undefined behavior if the file descriptor is not valid (it does, however, seem to work fine on Linux).

remove :: Fd -> FdSet -> IO FdSetSource

Remove a file descriptor.

removeList :: [Fd] -> FdSet -> IO FdSetSource

Remove multiple file descriptors. This is more efficient than multiple removes (only a single copy of the set is made).

inList :: [Fd] -> FdSet -> IO [Fd]Source

inList fds fdset gives a list of all file descriptors in fd that are in fdset.

inRange :: Fd -> BoolSource

Test if a file descriptor is in range (see introduction).

bound :: FdSet -> FdSource

This file descriptor is at least as large as the largest in the set. If no file descriptors have ever been removed from the set, the value is the largest in the set, but this assumption may not hold after removals or other operations.

duplicate :: FdSet -> IO FdSetSource

Copy an FdSet.