Safe Haskell | None |
---|
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 FdSet
s 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.
- 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
Documentation
fromList :: [Fd] -> IO FdSetSource
Create an FdSet
from a list of file descriptors. File
descriptors not in range (see above) are silently ignored.
insertList :: [Fd] -> FdSet -> IO FdSetSource
Insert multiple file descriptors. This is more efficient than
multiple insert
s (only a single copy of the set is made).
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).
removeList :: [Fd] -> FdSet -> IO FdSetSource
Remove multiple file descriptors. This is more efficient than
multiple remove
s (only a single copy of the set is made).
inList :: [Fd] -> FdSet -> IO [Fd]Source
gives a list of all file descriptors in
inList
fds fdsetfd
that are in fdset
.
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.