Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
1.4 KiB

  1. .TH iob_write 3
  2. .SH NAME
  3. iob_write \- send I/O batch through callback
  4. .SH SYNTAX
  5. .B #include <iob.h>
  6. typedef int64 (*io_write_callback)(int64 s,const void* buf,uint64 n);
  7. int64 \fBiob_write\fR(int64 s,io_batch* b,io_write_callback cb);
  8. .SH DESCRIPTION
  9. iob_write sends the (rest of) \fIb\fR through the callback \fIcb\fR,
  10. passing \fIs\fR as first argument. \fIcb\fR is expected to behave like
  11. io_trywrite(2).
  12. This interface is intended to send an I/O batch through a filter, for
  13. example to encrypt or compress it. If you just want to send an I/O
  14. batch to a socket, use iob_send instead.
  15. iob_write returns the number of bytes written, 0 if there were no more
  16. bytes to be written in the batch, -1 for EAGAIN, or -3 for a permanent
  17. error (for example "connection reset by peer").
  18. The normal usage pattern is using io_wait to know when a descriptor is
  19. writable, and then calling iob_write until it returns 0, -1 or -3.
  20. If it returns 0, terminate the loop (everything was written OK). If it
  21. returns -1, call io_wait again. If it returned -3, signal an error.
  22. .SH NOTE
  23. iob_write will continue to call your callback until it returns an error.
  24. So if you are in a state machine, for example a web server using this
  25. for SSL support, make sure to write at most n bytes at a time (e.g. 64k)
  26. and the next time you are called return -1. Otherwise iob_write might
  27. not return until the whole file is served.
  28. .SH "SEE ALSO"
  29. iob_send(3)