socket_listen(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_listen β€” bestie's guide to opening the door πŸ’–

okay so this page is socket_listen(3), and it lives in the Library Functions Manual section of the libowfat docs. pull up a chair, we're learning how to make your lil TCP socket start accepting friends 🫢


✨ NAME ✨

socket_listen β€” the manpage literally says "attempt to make a TCP connection", which, no shade, is not quite what it does (it's the listening side, bestie), but that's what's written so that's what you get πŸ’€


πŸŽ€ SYNTAX πŸŽ€

#include <libowfat/socket.h>

int socket_listen(int s,int n);

🌸 DESCRIPTION 🌸

so socket_listen gets your TCP socket s all dolled up to accept TCP connections πŸ‘‘ it lets a backlog of approximately n TCP SYNs hang out in the queue.

heads up: on systems that support SYN cookies, the backlog is irrelevant. the kernel's doing its own thing and your n is just vibing. no cap.

normally, socket_listen returns 0. slay, standard.

but if anything goes wrong? it returns -1 and sets errno appropriately so you know exactly what happened. not me being a responsible API πŸ’…


πŸ¦‹ EXAMPLE πŸ¦‹

here's the whole vibe, copy-paste ready:

#include <libowfat/socket.h>

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

if ((s=socket_tcp6())==-1)
  strerr_die2sys(111,FATAL,"unable to create TCP socket: ");
if (socket_bind6_reuse(s,(char *)V6any,8002,0) == -1)
  strerr_die2sys(111,FATAL,"unable to bind: ");
if (socket_listen(s,1) == -1)
  strerr_die2sys(111,FATAL,"unable to listen: ");

create it, bind it, listen on it. three steps, main character energy, periodt ✨


πŸ’œ SEE ALSO πŸ’œ

(the other side of the convo, iykyk 🧚)


and that's the whole page, bestie πŸ“ this was pulled from the Library Functions Manual for libowfat, and the lil footer at the bottom is just the page signing off as socket_listen(3) β€” no version number, no date, just a name drop 😭 go forth and listen πŸ’–πŸ”₯