[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.21.10 I/O multiplexing

The interface functions for select(2). The higher level interface is provided on top of these primitives; see 9.17 gauche.selector - Simple dispatcher.

Builtin Class: <sys-fdset>
Represents fd_set, a set of file descriptors. You can make an empty file descriptor set by make method:
(make <sys-fdset>)

Function: sys-fdset-ref fdset port-or-fd
Function: sys-fdset-set! fdset port-or-fd flag
Gets and sets specific file descritor bit of fdset. port-or-fd may be a port or an integer file descriptor. If port-or-fd is a port that doesn't have associated file descriptor, sys-fdset-ref returns #f, and sys-fdset-set! doesn't modify fdset. flag must be a boolean value.

You can use generic setter of sys-fdset-ref as this:
(set! (sys-fdset-ref fdset port-or-fd) flag)
  == (sys-fdset-set! fdset port-or-fd flag)

Function: sys-fdset-max-fd fdset
Returns the maximum file descriptor number in fdset.

Function: sys-select readfds writefds exceptfds &optional timeout
Function: sys-select! readfds writefds exceptfds &optional timeout
Waits for a set of file descriptors to change status. readfds, writefds, and exceptfds are <fdset> objects to represent a set of file descriptors to watch. File descriptors in readfds are watched to see if characters are ready to be read. File descriptors in writefds are watched if writing to them is ok. File descriptors in exceptfds are watched for exceptions. You can pass #f to one or more of those arguments if you don't care about watching the condition.

timeout specifies maximum time sys-select waits for the condition change. It can be a real number, for number of microseconds, or a list of two integers, the first is the number of seconds and the second is the number of microseconds. If you pass #f, sys-select waits indefinitely.

sys-select returns four values. The first value is a number of descriptors it detected status change. It may be zero if timeout expired. The second, third and fourth values are <fdset> object that contains a set of descriptors that changed status for reading, writing, and exception, respectively. If you passed #f to one or more of readfds, writefds and exceptfds, the corresponding return value is #f.

sys-select! variant works the same as sys-select, except it modifies the passed <fdset> arguments. sys-select creates new <fdset> objects and doesn't modify its arguments.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html