SOCKET_ACCEPT6_SETCLOSEONEXEC(3)

✨ socket_accept6_setcloseonexec ✨

okay bestie, so this one lives in the Library Functions Manual and it's literally called socket_accept6_setcloseonexec β€” yes the name is a whole sentence, we love a verbose king πŸ’…


🌸 NAME 🌸

socket_accept6_setcloseonexec β€” accept an IPv6 TCP connection on a socket πŸ¦‹


πŸŽ€ SYNTAX πŸŽ€

#include <libowfat/socket.h>

int socket_accept6_setcloseonexec(int s,char ip[16],uint16 *port,uint32 *scope_id);

πŸ’– DESCRIPTION πŸ’–

so basically, this is functionally equivalent to calling socket_accept4 and then calling io_closeonexec on the socket it hands back. same energy, same result, no cap 🫢

but here's the glow-up: it may save a syscall or two, and while it's doing that it also avoids a race condition ✨ which is honestly the main character move here. iconic behavior fr fr.


🌈 EXAMPLE 🌈

#include <libowfat/socket.h>

int s;
char ip[16];
uint16 port;
uint32 scope_id;

s = socket_tcp6();
socket_bind6(s,ip,port,scope_id);
socket_listen(s,16);
socket_accept6_setcloseonexec(s,ip,&port,&scope_id);

look at her go 😭 she's doing it, she's accepting connections


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page, bestie πŸ’œ it's from the Library Functions Manual, and the page is literally just socket_acc...closeonexec(3) (yes they truncated her name, tragic, but that's the vibe). go forth and accept your IPv6 connections responsibly 🌟 mwah πŸ’‹