Next: , Previous: , Up: Event Dispatching with SERVE-EVENT   [Contents][Index]


7.3 Using SERVE-EVENT with Unix File Descriptors

Object sets are not available for use with file descriptors, as there are only two operations possible on file descriptors: input and output. Instead, a handler for either input or output can be registered with system:serve-event for a specific file descriptor. Whenever any input shows up, or output is possible on this file descriptor, the function associated with the handler for that descriptor is funcalled with the descriptor as it’s single argument.

Function: system:add-fd-handler fd direction function

This function installs and returns a new handler for the file descriptor fd. direction can be either :input if the system should invoke the handler when input is available or :output if the system should invoke the handler when output is possible. This returns a unique object representing the handler, and this is a suitable argument for system:remove-fd-handler function must take one argument, the file descriptor.

Function: system:remove-fd-handler handler

This function removes handler, that add-fd-handler must have previously returned.

Macro: system:with-fd-handler (fd direction function) {form}*

This macro executes the supplied forms with a handler installed using fd, direction, and function. See system:add-fd-handler. The given forms are wrapped in an unwind-protect; the handler is removed (see system:remove-fd-handler) when done.

Function: system:wait-until-fd-usable fd direction &optional timeout

This function waits for up to timeout seconds for fd to become usable for direction (either :input or :output). If timeout is nil or unspecified, this waits forever.

Function: system:invalidate-descriptor fd

This function removes all handlers associated with fd. This should only be used in drastic cases (such as I/O errors, but not necessarily EOF). Normally, you should use remove-fd-handler to remove the specific handler.


Next: Using SERVE-EVENT with the CLX Interface to X, Previous: The SERVE-EVENT Function, Up: Event Dispatching with SERVE-EVENT   [Contents][Index]