io_wantwrite(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

πŸ’– io_wantwrite β€” signal that you want to write to a descriptor πŸ’–

okay bestie, you're reading io_wantwrite(3) from the Library Functions Manual and honestly? it's giving "I have something to say and I need the event loop to know" 🌸


✨ SYNTAX ✨

#include <libowfat/io.h>

void io_wantwrite(int64 fd);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so io_wantwrite is you sliding into the DMs of the next io_wait() to be like "hey. I want to write to this descriptor." that's it. that's the whole vibe. πŸ’…

and if you change your mind? no worries, just call io_dontwantwrite() again and we pretend it never happened πŸ™ˆ

the next time you call io_wait(), it will look whether this descriptor becomes writeable, too. and then you can use io_canwrite() to check whether the descriptor has become writable. so the pipeline is: you say you want it, io_wait() goes and peeks, io_canwrite() tells you if the moment has arrived. iconic teamwork, no cap 🫢

⚠️ but listen β€” you have to have called io_fd on the descriptor first. not optional. io_pipe and io_socketpair do this for you though, so if you came in through one of those doors you're already slaying πŸ’–

and here's the lowkey important part: waiting on descriptors only works for sockets, fifos and pipes. it may also work on devices and TTYs, but that is platform dependent β€” you should not rely on that. fr fr, don't build your whole personality on it 😭


🌈 SEE ALSO 🌈


and that's the page, bestie πŸ’œ this was io_wantwrite(3) straight outta the Library Functions Manual, brought to you by the fine folks who make your event loop go brrr. go forth and write βœ¨πŸŽ€πŸ¦‹