io_fd_canwrite(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_canwrite πŸ’–

bestie, this is a page from the Library Functions Manual, and it's literally all about getting a file descriptor ready for io_wait. no cap. πŸ¦‹


✨ NAME ✨

io_fd_canwrite β€” get that descriptor prepped for io_wait πŸ’…


🌸 SYNTAX 🌸

#include <libowfat/io.h>

int io_fd(int64 fd); int io_fd_canwrite(int64 fd);

yes bestie, both of them, right there in one header. iconic.


πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea πŸ“: io_fd_canwrite is just like io_fd, except it assumes the descriptor is writable, which can save you a syscall or two. and honestly? that assumption is true in most cases, because the kernel buffers writes. slay.

but listen, there are some noteworthy cases where you have to use io_fd instead of io_fd_canwrite, and they matter:

  • unconnected sockets β€” like when you queued a non-blocking connect() and you want to ask for writability so you get notified when it went through. 🫢
not me casually skipping this and then wondering why my socket never tells me anything 😭 use io_fd for that one, fr fr.

and the good news: it is OK to call this function on a descriptor that io_fd() has already been called on. no drama, no double-registration meltdown. we love a flexible API. ✨


πŸ’€ RETURN VALUE πŸ’€

  • io_fd_canwrite returns 1 on success, 0 on error.

that's it. that's the whole vibe check. πŸ”₯


🌈 SEE ALSO 🌈

go read these too, they're all part of the same friend group:


and that's the page!! πŸŽ€ it's from the Library Functions Manual, and the footer at the bottom just says io_fd_canwrite(3) again because it wanted to make sure you remembered the name. main character energy honestly. go prep those descriptors, bestie πŸ’œπŸ§š