Next: , Up: posix fd select   [Index]


4.13.6.1 Allocating and accessing file descriptor sets

At low level, the POSIX function select() keeps track of file descriptors organised in sets, represented by instances of the C language type fd_set; we can think of such data structures as arrays of integers, holding FD_SETSIZE bits, in which each bit represents a file descriptor: 1 for inclusion, 0 for exclusion.

Function: sizeof-fd-set
Function: sizeof-fd-set count

Return an exact integer representing the number of bytes needed to hold count instances of the C language type fd_set. The optional count must be a positive fixnum; when not given: it defaults to 1.

Function: make-fd-set-bytevector
Function: make-fd-set-bytevector count

Build and return a new bytevector capable of holding count instances of the C language type fd_set defined in sys/types.h; every allocated fd_set is initialised with FD_ZERO(). The optional count must be a positive fixnum; when not given: allocate enough room for a single instance of fd_set.

Function: make-fd-set-pointer
Function: make-fd-set-pointer count

Use malloc() to allocate a memory block capable of holding count instances of the C language type fd_set defined in sys/types.h; every allocated fd_set is initialised with FD_ZERO().

The optional count must be a positive fixnum; when not given: allocate enough room for a single instance of fd_set.

If successful: return a pointer object referencing the memory block; else return #f.

Function: make-fd-set-memory-block
Function: make-fd-set-memory-block count

Use malloc() to allocate a memory block capable of holding count instances of the C language type fd_set defined in sys/types.h; every allocated fd_set is initialised with FD_ZERO().

The optional count must be a positive fixnum; when not given: allocate enough room for a single instance of fd_set.

If successful: return an instance of memory-block referencing the memory block; else return #f.

Function: FD_ZERO fdsets
Function: FD_ZERO fdsets idx

Reset to empty the given file descriptor set; return unspecified values; (libc)FD_ZERO.

fdsets must be a bytevector, pointer object or memory-block instance holding or referencing one or more instances of the C language type fd_set.

idx must be a non–negative fixnum representing the index of the selected fd_set in fdsets; when not given: it defaults to zero.

Function: FD_SET fd fdsets
Function: FD_SET fd fdsets idx

Add the file descriptor fd to the given set; return unspecified values; (libc)FD_SET.

fdsets must be a bytevector, pointer object or memory-block instance holding or referencing one or more instances of the C language type fd_set.

The optional idx must be a non–negative fixnum representing the index of the selected fd_set in fdsets; when not given: it defaults to zero.

Function: FD_CLR fd fdsets
Function: FD_CLR fd fdsets idx

Remove the file descriptor fd from the given set; return unspecified values; (libc)FD_CLR.

fdsets must be a bytevector, pointer object or memory-block instance holding or referencing one or more instances of the C language type fd_set.

The optional idx must be a non–negative fixnum representing the index of the selected fd_set in fdsets; when not given: it defaults to zero.

Function: FD_ISSET fd fdsets
Function: FD_ISSET fd fdsets idx

Return a boolean specifying if the file descriptor fd is contained in the given set; return unspecified values; (libc)FD_ISSET.

fdsets must be a bytevector, pointer object or memory-block instance holding or referencing one or more instances of the C language type fd_set.

The optional idx must be a non–negative fixnum representing the index of the selected fd_set in fdsets; when not given: it defaults to zero.

Function: fd-set-inspection fdsets
Function: fd-set-inspection fdsets idx

Return a list of fixnums representing the file descriptors set in the selected fd_set structure. This function is for debugging purposes.

fdsets must be a bytevector, pointer object or memory-block instance holding or referencing one or more instances of the C language type fd_set.

The optional idx must be a non–negative fixnum representing the index of the selected fd_set in fdsets; when not given: it defaults to zero.


Next: , Up: posix fd select   [Index]