socket_acc...onblocking(3)
π socket_acc...onblocking β the manual, but make it cute π
okay bestie, welcome to the socket_acc...onblocking(3) page from the Library Functions Manual π«Ά this one's short but it's iconic, lowkey a whole sleeper hit. sit down, hydrate, let's go β¨
β¨ NAME β¨
socket_accept4_makenonblocking β accept an IPv4 TCP connection on a socket and set it to non-blocking I/O π
like. the name literally tells you the whole plot. accept a v4 TCP connection, then boom, non-blocking. no cap. πΈ
π SYNTAX π
#include <libowfat/socket.h>
int socket_accept4_makenonblocking(int s,char ip[4],uint16 *port);
so you pass in s (the socket), ip[4] (a char array of 4, the v4 address goes here), and port (a pointer to a uint16), and you get back an int. that's the whole vibe check. π
π DESCRIPTION π
okay so here's the tea π β this function is functionally equivalent to calling socket_accept4 and then calling ndelay_on on the socket you got back. literally the same result. same energy.
BUT. and this is the part that's giving main character π β it may save a syscall or two, and in the process it can avoid a race condition. so it's not just cute, it's smart. the way that it's both?? obsessed. π
not me being dramatic but "avoids a race condition" is genuinely the slay here. race conditions are the villain of this whole story and this function simply refuses to participate. π§
πΈ EXAMPLE πΈ
here's how the girlies actually use it:
#include <libowfat/socket.h>
int s;
char ip[4];
uint16 p;
s = socket_tcp4();
socket_bind4(s,ip,p);
socket_listen(s,16);
socket_accept4_makenonblocking(s,ip,&p);
make the socket, bind it, listen on it (backlog of 16, periodt), then accept the connection and get it non-blocking in one move. ate. π₯
π SEE ALSO π
your reading list, bestie, go off:
socket_accept4(3)socket_connected(3)socket_accept6_makenonblocking(3)socket_accept4_setcloseonexec(3)socket_accept4_makenonblocking_setcloseonexec(3)
π and that's the page!! this was socket_acc...onblocking(3) from the Library Functions Manual, and yes the name gets truncated in the header and footer because even man pages have to fit in the group chat. mwah, study safe, and remember: non-blocking is a lifestyle π
β¨π¦
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· 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 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