SOCKET_ACCEPT6_MAKENONBLOCKING_SETCLOSEONEXEC(3)

πŸ“¦
version 0.34 Β· 2 versions
, in alpine 3.24, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay bestie, welcome to socket_acc...closeonexec(3) from the Library Functions Manual β€” yes, the title is a whole mouthful and it ate πŸ’…

socket_accept6_makenonblocking_setcloseonexec β€” accept an IPv6 TCP connection on a socket and set it to non-blocking I/O and close-on-exec. iconic behavior, honestly πŸŽ€

#include <libowfat/socket.h>

int socket_accept6_makenonblocking_setcloseonexec(int s,char
ip[4],uint16 *port,uint16* scope_id);

🌸 DESCRIPTION 🌸

This is functionally equivalent to calling socket_accept6 and then calling ndelay_on and io_tcloseonexec on the returned socket. like, same energy, same result πŸ’–

However, if may save a syscall or two and in the process avoid a race condition β€” yes, that's literally how the original words it, and the vibe is very "trust me bestie" 😭πŸ”₯ no cap, fewer syscalls and no race condition is a slay.


✨ EXAMPLE ✨

#include <libowfat/socket.h>

int s;
char ip[16];
uint16 p;
uint16 scope_id;

s = socket_tcp6();
socket_bind6(s,ip,p,scope_id);
socket_listen(s,16);
socket_accept6_makenonblocking_setcloseonexec(s,ip,&p,&scope_id);

copy it exactly, bestie β€” the ip[16] here and the ip[4] in the signature are both giving main character energy, so we keep them as written πŸ«ΆπŸ’€


πŸŽ€ SEE ALSO πŸŽ€


source/version/date sign-off: the footer only gives socket_acc...closeonexec(3) β€” no extra source, version, or date info shows up on this page, so that's the whole metadata moment 🫢✨