DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Asynchronous I/O

Using the interface functions

This section tells you how to use the four interface functions:

aio_read and aio_write

aio_read and aio_write allow an application to request an asynchronous read or asynchronous write operation. When initiating an asynchronous read or write, you can request asynchronous notification by supplying the address of a user-defined handler to be invoked when the I/O has completed. Since the address of the aiocb control block is passed as an argument to the handler, the I/O request that completed is easily identified and you need only implement one handler.

aio_suspend

An application may request asynchronous notification by supplying the address of a user-defined handler to be called on completion of the Asynchronous I/O request. This enables the application to perform other work while the I/O is in progress and guarantees that the application will be notified at the time the I/O completes so that any processing on that data may be performed immediately, if so desired.

For threads-based Asynchronous I/O, an application may also use the aio_suspend interface to block until at least one I/O operation completes or a timeout period expires. This interface is flexible because it enables any thread within a process to ask about one or more outstanding Asynchronous I/O operations and can specify how long to wait.

The aio_suspend routine returns 0 if at least one matching I/O request completed.

A null pointer is returned on failure and errno is set to indicate that the timeout expired (ETIME) or an interrupt occurred (EINTR).

aio_cancel

Although rarely needed, aio_cancel is the only way to cancel an Asynchronous I/O request that has been blocked for input from a remote host that just crashed. Requests that have not been started are canceled, but those in progress may or may not be canceled.


Next topic: Using other system calls with asynchronous I/O
Previous topic: Error behavior

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005