1iob_write(3)               Library Functions Manual               iob_write(3)
2
3
4

NAME

6       iob_write - send I/O batch through callback
7

SYNTAX

9       #include <iob.h>
10
11       typedef int64 (*io_write_callback)(int64 s,const void* buf,uint64 n);
12
13       int64 iob_write(int64 s,io_batch* b,io_write_callback cb);
14

DESCRIPTION

16       iob_write  sends  the (rest of) b through the callback cb, passing s as
17       first argument.  cb is expected to behave like io_trywrite(2).
18
19       This interface is intended to send an I/O batch through a  filter,  for
20       example  to  encrypt  or  compress it.  If you just want to send an I/O
21       batch to a socket, use iob_send instead.
22
23       iob_write returns the number of bytes written, 0 if there were no  more
24       bytes  to be written in the batch, -1 for EAGAIN, or -3 for a permanent
25       error (for example "connection reset by peer").
26
27       The normal usage pattern is using io_wait to know when a descriptor  is
28       writable, and then calling iob_write until it returns 0, -1 or -3.
29
30       If it returns 0, terminate the loop (everything was written OK).  If it
31       returns -1, call io_wait again.  If it returned -3, signal an error.
32
33

NOTE

35       iob_write will continue to call  your  callback  until  it  returns  an
36       error.   So  if  you  are  in a state machine, for example a web server
37       using this for SSL support, make sure to write at most  n  bytes  at  a
38       time  (e.g. 64k) and the next time you are called return -1.  Otherwise
39       iob_write might not return until the whole file is served.
40
41

SEE ALSO

43       iob_send(3)
44
45
46
47                                                                  iob_write(3)
Impressum