socket_recv6(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_recv6(3) β€” bestie edition πŸ’–

from the Library Functions Manual, aka the sacred texts ✨


🌸 NAME 🌸

socket_recv6 β€” receive a UDP datagram 🫢


✨ SYNTAX ✨

okay so first you gotta include the header, no cap:

#include <libowfat/socket.h>

ssize_t socket_recv6(int s, char* buf, size_t len,
        char ip[16], uint16* port, uint32* scope_id);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically socket_recv6 receives up to len bytes starting at buf from a UDP datagram that came in on the socket s. it writes the UDP port to port and the IP address to ip, and it returns the number of bytes actually received β€” or -1 if anything went wrong 😭.

for link-local addresses, scope_id will become the network interface number, which you can translate into the actual name of the interface (like "eth0") using socket_getifname. iykyk πŸ’…


πŸ‘‘ RETURN VALUE πŸ‘‘

  • if a datagram was received, socket_recv6 returns the number of bytes in it πŸ’–
  • if not, it returns -1 and sets errno appropriately 🚩

🌈 EXAMPLE 🌈

here's the vibe, literally copy-paste energy:

#include <libowfat/socket.h>

int s;
char ip[16];
uint16 p;
char buf[1000];
int len;
uint32 scope_id;

s = socket_tcp4();
socket_bind6(s,ip,p);
len = socket_recv6(s,buf,sizeof(buf),ip,&p,&scope_id);

πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page bestie, go forth and receive those datagrams 🧚✨

this lil masterpiece lives in the Library Functions Manual, and the footer is just the page name again β€” socket_recv6(3) β€” like a lil signature at the bottom πŸ’œ slay.