io_fd_flags(3)
π 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_flagsonly exists ifHAVE_IO_FD_FLAGSis defined, so keep an eye on that#ifdefbestie, 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 tellsio_fdthat the descriptor is writable. super useful because it meansio_wantwritecan queue the descriptor immediately and there's no need to go query the operating system event reporting mechanism. efficiency, slay. βIO_FD_BLOCKβ tellsio_fdthat the descriptor is blocking.IO_FD_NONBLOCKβ tellsio_fdthat 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 bothIO_FD_BLOCKandIO_FD_NONBLOCKat 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 ππβ¨
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms