io_fd_flags(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_fd_flags β€” the vibe check for your file descriptors ✨

okay bestie, so this is a page from the Library Functions Manual, and it's all about io_fd_flags(3) β€” the glow-up version of io_fd that lets you tell the library stuff instead of making it go ask the operating system. it's giving "I already know, don't @ me" energy 🫢


🌸 NAME 🌸

io_fd_flags β€” get your descriptor all prepped and pretty for io_wait πŸ’…


✨ SYNTAX ✨

#include <libowfat/io.h>

int io_fd(int64 fd);

#ifdef HAVE_IO_FD_FLAGS

int io_fd_flags(int64 fd);
lowkey important: io_fd_flags only exists if HAVE_IO_FD_FLAGS is defined, so keep an eye on that #ifdef bestie, it's not decorative πŸŽ€

πŸ’œ DESCRIPTION πŸ’œ

okay so io_fd_flags literally behaves exactly like io_fd, no notes, same queen, same everything β€” except you can bitwise-OR certain flags onto it to change how it acts. like little accessories for your descriptor. obsessed. πŸ¦‹

Here's the flag lineup, no skips:

  • IO_FD_CANWRITE β€” this one tells io_fd that the descriptor is writable. super useful because it means io_wantwrite can queue the descriptor immediately and there's no need to go query the operating system event reporting mechanism. efficiency, slay. ⭐
  • IO_FD_BLOCK β€” tells io_fd that the descriptor is blocking.
  • IO_FD_NONBLOCK β€” tells io_fd that the descriptor is non-blocking.

Now the lore: normally, io_fd calls fcntl to go ask the operating system whether the descriptor is blocking or not. it's nosy like that πŸ™ˆ. and the framework genuinely needs to know, because it changes how io_tryread and io_trywrite handle the socket. so this info is not optional gossip, it's load-bearing.

πŸ’€ NEVER pass both IO_FD_BLOCK and IO_FD_NONBLOCK at the same time. that's contradictory, bestie, pick a lane. that's a vibe check failure, fr fr.

More lore for you: newly connected stream sockets are always writable if the connection is established, so it's usually safe to pass IO_FD_CANWRITE and move on with your day. ✨

the one big exception β€” the "not me" moment β€” is a non-blocking socket where a connect() is pending. in that case you should not pass IO_FD_CANWRITE. instead you need to poll for writability so you get notified when the connection is actually established. the way that connect() just takes its time 😭


πŸ”₯ RETURN VALUE πŸ”₯

io_fd_flags returns 1 on success and 0 on error. that's it, that's the whole drama. πŸ‘‘


🌈 SEE ALSO 🌈


and that's the page, bestie!! this was the Library Functions Manual entry for io_fd_flags(3), filed under that exact name at the very bottom of the original. go forth and prep those descriptors, you absolute icon πŸ‘‘πŸ’–βœ¨