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 iob_write returns 0, terminate the loop (everything was written OK).
31       If it returns -1, call io_wait again.  If it  returned  -3,  signal  an
32       error.
33
34       The  callback is supposed to behave like write(2), i.e. return the num‐
35       ber of bytes written, 0 for EOF, -1 for error (iob_write will return -3
36       then).   Return -1 with errno==EAGAIN if using non-blocking I/O when we
37       need to wait for the next write event.  iob_write will then return -1.
38
39

NOTE

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

SEE ALSO

49       iob_send(3)
50
51
52
53                                                                  iob_write(3)
Impressum