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

✨ socket_fastopen ✨

okay bestie, so this is a lil page from the Library Functions Manual about socket_fastopen(3) β€” yes that's the whole vibe, we're doing TCP Fast Open on the server side today, and honestly? iconic. πŸ’…


πŸŽ€ NAME πŸŽ€

socket_fastopen β€” turning on TCP Fast Open for a server-side TCP socket, no cap ✨


πŸ¦‹ SYNTAX πŸ¦‹

#include <libowfat/socket.h>

int socket_fastopen(int s);

like literally just that. one include, one call, we're so back 🫢


🌸 DESCRIPTION 🌸

okay so socket_fastopen does exactly what it says on the tin: it enables TCP Fast Open support on a server-side TCP socket. that's the whole job. main character energy fr fr πŸ‘‘

the timing matters though!! you gotta call this before socket_listen(). like, before. not after. not during. before. the way that order is non-negotiable 😭

now, plot twist: if your platform just does not support this functionality, it returns -1 and sets errno to ENOPROTOOPT β€” or ENOSYS if the platform doesn't even define ENOPROTOOPT. so yeah, sometimes the platform is the problem, not you. πŸ’€

normally though? socket_fastopen returns 0. and if anything goes wrong, it returns -1 and sets errno appropriately. simple as that, periodt ✨

ngl, that -1 return is your vibe check β€” if you see it, something said no. go check errno, bestie. πŸ”₯

🌈 EXAMPLE 🌈

here's the whole lil routine, exactly as it's written:

#include <libowfat/socket.h>

int s;
char ip[4];
uint16 p;

s = socket_tcp4b();
socket_fastopen(s);
socket_bind4_reuse(s,ip,p);
socket_listen(16);

see how socket_fastopen(s) comes in before socket_listen(16)? that's the order, bestie. we love a sequence πŸŽ€


πŸ’– SEE ALSO πŸ’–

go read those too, they're the client-side besties πŸ¦‹


and that's the page!! this one lives in the Library Functions Manual and it's filed under socket_fastopen(3) β€” shoutout to the man page for being short, sweet, and to the point. ily, go enable TCP Fast Open responsibly πŸ«Άβœ¨πŸ’–