/*++ /* NAME /* nbbio 3 /* SUMMARY /* non-blocking buffered I/O /* SYNOPSIS /* #include <nbbio.h> /* /* NBBIO *nbbio_create(fd, bufsize, label, action, context) /* int fd; /* ssize_t bufsize; /* const char *label; /* void (*action)(int event, void *context); /* char *context; /* /* void nbbio_free(np) /* NBBIO *np; /* /* void nbbio_enable_read(np, timeout) /* NBBIO *np; /* int timeout; /* /* void nbbio_enable_write(np, timeout) /* NBBIO *np; /* int timeout; /* /* void nbbio_disable_readwrite(np) /* NBBIO *np; /* /* void nbbio_slumber(np, timeout) /* NBBIO *np; /* int timeout; /* /* int NBBIO_ACTIVE_FLAGS(np) /* NBBIO *np; /* /* int NBBIO_ERROR_FLAGS(np) /* NBBIO *np; /* /* const ssize_t NBBIO_BUFSIZE(np) /* NBBIO *np; /* /* ssize_t NBBIO_READ_PEND(np) /* NBBIO *np; /* /* char *NBBIO_READ_BUF(np) /* NBBIO *np; /* /* const ssize_t NBBIO_WRITE_PEND(np) /* NBBIO *np; /* /* char *NBBIO_WRITE_BUF(np) /* NBBIO *np; /* DESCRIPTION /* This module implements low-level support for event-driven /* I/O on a full-duplex stream. Read/write events are handled /* by pseudothreads that run under control by the events(5) /* module. After each I/O operation, the application is /* notified via a call-back routine. /* /* It is up to the call-back routine to turn on/off read/write /* events as appropriate. It is an error to leave read events /* enabled for a buffer that is full, or to leave write events /* enabled for a buffer that is empty. /* /* nbbio_create() creates a pair of buffers of the named size /* for the named stream. The label specifies the purpose of /* the stream, and is used for diagnostic messages. The /* nbbio(3) event handler invokes the application call-back /* routine with the current event type (EVENT_READ etc.) and /* with the application-specified context. /* /* nbbio_free() terminates any pseudothreads associated with /* the named buffer pair, closes the stream, and destroys the /* buffer pair. /* /* nbbio_enable_read() enables a read pseudothread (if one /* does not already exist) for the named buffer pair, and /* (re)starts the buffer pair's timer. It is an error to enable /* a read pseudothread while the read buffer is full, or while /* a write pseudothread is still enabled. /* /* nbbio_enable_write() enables a write pseudothread (if one /* does not already exist) for the named buffer pair, and /* (re)starts the buffer pair's timer. It is an error to enable /* a write pseudothread while the write buffer is empty, or /* while a read pseudothread is still enabled. /* /* nbbio_disable_readwrite() disables any read/write pseudothreads /* for the named buffer pair, including timeouts. To ensure /* buffer liveness, use nbbio_slumber() instead of /* nbbio_disable_readwrite(). It is no error to call this /* function while no read/write pseudothread is enabled. /* /* nbbio_slumber() disables any read/write pseudothreads for /* the named buffer pair, but keeps the timer active to ensure /* buffer liveness. It is no error to call this function while /* no read/write pseudothread is enabled. /* /* NBBIO_ERROR_FLAGS() returns the error flags for the named buffer /* pair: zero or more of NBBIO_FLAG_EOF (read EOF), NBBIO_FLAG_ERROR /* (read/write error) or NBBIO_FLAG_TIMEOUT (time limit /* exceeded). /* /* NBBIO_ACTIVE_FLAGS() returns the pseudothread flags for the /* named buffer pair: NBBIO_FLAG_READ (read pseudothread is /* active), NBBIO_FLAG_WRITE (write pseudothread is active), /* or zero (no pseudothread is active). /* /* NBBIO_WRITE_PEND() and NBBIO_WRITE_BUF() evaluate to the /* number of to-be-written bytes and the write buffer for the /* named buffer pair. NBBIO_WRITE_PEND() must be updated by /* the application code that fills the write buffer; no more /* than NBBIO_BUFSIZE() bytes may be filled. /* /* NBBIO_READ_PEND() and NBBIO_READ_BUF() evaluate to the /* number of unread bytes and the read buffer for the named /* buffer pair. NBBIO_READ_PEND() and NBBIO_READ_BUF() must /* be updated by the application code that drains the read /* buffer. /* SEE ALSO /* events(3) event manager /* DIAGNOSTICS /* Panic: interface violation. /* /* Fatal: out of memory. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Wietse Venema /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA
/*--*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.