iob_send(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– iob_send β€” send I/O batch πŸ’–

okay bestie, welcome to iob_send(3) from the Library Functions Manual ✨ this is the one that actually pushes your whole batch of buffered stuff out the door, no cap πŸšͺπŸ’¨


✨ SYNTAX ✨

#include <libowfat/iob.h>

int64 iob_send(int64 s,io_batch* b);

πŸ¦‹ DESCRIPTION πŸ¦‹

So like. iob_send sends the (rest of) b over the socket s. that's it, that's the whole job πŸ’… note the rest of β€” if you already sent part of it, it just picks up where it left off, it's not re-sending anything, she's efficient like that 🫢

Here's the tea on what she returns πŸ‘‡

  • the number of bytes written β€” yay, progress πŸŽ‰
  • 0 β€” there were no more bytes to be written in the batch, we're done here bestie βœ…
  • -1 β€” for EAGAIN, aka "not right now, try again later" 😴
  • -3 β€” a permanent error (for example "connection reset by peer") πŸ’€ that one's for real

The normal usage pattern is using io_wait to know when a descriptor is writable, and then calling iob_send until it returns 0, -1 or -3. it's giving loop energy, iykyk πŸ”

And the decision tree is literally so simple, memorise it fr fr:

  1. If it returns 0, terminate the loop (everything was written OK) πŸŽ€
  2. If it returns -1, call io_wait again πŸ”„
  3. If it returned -3, signal an error and close the socket 🚨
bestie. do not ignore the -3. that socket is gone. close it and move on, no main character denial arc 😭

Now why is this whole I/O batch API even iconic?? The benefit of the I/O batch API is that it exploits platform specific APIs like FreeBSD's sendfile πŸ‘‘ The file contents will always be sent in a way that allows the operating systems to perform zero copy TCP, and the buffers will always be sent using as few syscalls as possible and avoiding unnecessary copying (using writev). like... she's out here doing the least amount of work for the most amount of output, we stan an efficient queen 🌸🧚


🌈 SEE ALSO 🌈


and that's the page bestie 🫢 this was iob_send(3) from the Library Functions Manual β€” go forth and send ur batches, mwah πŸ’‹βœ¨