io_getcookie(3)
π io_getcookie(3) β the one where you get your cookie back π
Library Functions Manual Β· a libowfat moment β¨
β¨ NAME β¨
io_getcookie β retrieve cookie πͺ
πΈ SYNTAX πΈ
#include <libowfat/io.h>
void* io_getcookie(int64 fd);
bestie it literally takes one arg and hands you a pointer, we love a low-effort queen π
π¦ DESCRIPTION π¦
So io_getcookie retrieves a cookie β and by "cookie" we mean a pointer to some anonymous data structure you associated with this descriptor. It's giving secret lil treat for your fd, no cap π
Wanna set one? Use io_setcookie(3) to associate a cookie with a descriptor. That's the whole pipeline, you put the cookie in, you get the cookie out π«Ά
And if you did not associate a cookie with this descriptor, io_getcookie returns NULL. Like, respectfully, there was no cookie. Empty plate. Tragic but valid π
Now here's the actual galaxy-brain part, because this is the slay π₯ The idea is that you put the state associated with a TCP connection you serve in a common struct. Then you do not need to have your own data structure to retrieve the state for a connection β you can just use the data structure io_wait already maintains. The way that this means zero extra bookkeeping on your end, we're obsessed fr fr π
And the lookup itself? It works in constant time and should not cause any cache misses. The performance is genuinely iconic, no notes β
ngl this is the part where you stop writing your own lookup table and just let io_wait carry the whole thing, main character energy π
π SEE ALSO π
go read io_setcookie(3) next so you actually have a cookie to get, iykyk π
okay that's the whole page bestie, ty for reading, mwah π this was the io_getcookie(3) entry from the Library Functions Manual, brought to you by libowfat, and yes the footer is literally just io_getcookie(3) again because manpages are dramatic like that π
β¨
π¦ 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