FdSet is opaque, but is implemented internally as a
pointer to an
fd_set. All operations on
FdSets must adhere to
the requirements of
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-
In the documentation that follows, a file descriptor is said to be
in range if it is non-negative and strictly smaller than the
FD_SETSIZE. Many functions silently ignore file
descriptors that are not in range.
- data FdSet
- fromList :: [Fd] -> IO FdSet
- insert :: Fd -> FdSet -> IO FdSet
- insertList :: [Fd] -> FdSet -> IO FdSet
- empty :: IO FdSet
- elem :: Fd -> FdSet -> IO Bool
- remove :: Fd -> FdSet -> IO FdSet
- removeList :: [Fd] -> FdSet -> IO FdSet
- inList :: [Fd] -> FdSet -> IO [Fd]
- inRange :: Fd -> Bool
- bound :: FdSet -> Fd
- duplicate :: FdSet -> IO FdSet
FdSet from a list of file descriptors. File
descriptors not in range (see above) are silently ignored.
Insert multiple file descriptors. This is more efficient than
inserts (only a single copy of the set is made).
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 multiple file descriptors. This is more efficient than
removes (only a single copy of the set is made).
gives a list of all file descriptors in
inList fds fdset
fd that are in
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.