socket_tcp4b(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_tcp4b β€” bestie edition πŸ’–

okay so we're in the Library Functions Manual today, and the star of the show is socket_tcp4b(3). pull up a chair, grab a boba, we're doing sockets πŸ§‹βœ¨


✨ NAME ✨

socket_tcp4b β€” create a blocking TCP/IP stream socket 🫢

like. that's it. that's the whole job. she's simple, she's reliable, she's iconic πŸ’…


🌸 SYNTAX 🌸

#include <libowfat/socket.h>

int socket_tcp4b();

yes bestie, that's the whole signature. no arguments, no drama, no nothing. she just exists and hands you a socket πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•

socket_tcp4b creates a blocking TCP/IP stream socket, and then it gives you back a file descriptor pointing at that socket. that fd is your new best friend. you use it for everything after this. protect it. cherish it. close it when you're done, fr fr πŸ™ˆ

and if something goes wrong?? 😭 she doesn't spiral, she doesn't leave a mess β€” socket_tcp4b returns -1, sets errno appropriately, and does it all without allocating any resources. no leftovers, no lingering allocations, nothing to clean up. she simply says "not today" and exits gracefully. that's main character energy, no cap πŸ‘‘

ngl the "without allocating any resources" part is lowkey the best part. if it fails, it fails clean. you don't have to go hunting for some half-created socket later. we love a tidy queen ✨

πŸ“ EXAMPLE πŸ“

here's what it looks like in the wild, copy-paste ready:

#include <libowfat/socket.h>

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

s = socket_tcp4b();
socket_bind4(s,ip,p);
socket_connect4(s,ip,p);

see how the vibe goes?? make the socket β†’ bind it β†’ connect it. that's the whole arc. a little three-act play and honestly? she ate πŸ’…


🌈 SEE ALSO 🌈

the girlies that go with this one, aka your required reading:


🫢 that's the page!! go forth and socket_tcp4b() responsibly. and remember: check your return value, bestie. -1 is not a personality trait, it's an error πŸ’€

this has been your girl, bringing you socket_tcp4b(3) straight outta the Library Functions Manual β€” mwah, love u, bye πŸ’–πŸŽ€πŸ¦‹