socket_send6(3)
π socket_send6 β bestie's guide to yeeting a UDP datagram into the void β¨
okay so real talk, this is a page from the Library Functions Manual about socket_send6(3), and it's literally so good. sit down, grab a strawberry drink π, and let's get into it.
πΈ NAME πΈ
socket_send6 β send a UDP datagram
π SYNTAX π
#include <libowfat/socket.h>
ssize_t socket_send6(int s, const char* buf, size_t len,
const char ip[16], uint16 port, uint32 scope_id);
π¦ DESCRIPTION π¦
so here's the tea, bestie π
β socket_send6 sends len bytes starting at buf in a UDP datagram over the socket s to UDP port port on IP address ip. that's it, that's the whole vibe.
and here's the part that's giving convenience: you can call socket_send6 without calling socket_bind6 first. no cap. it has the same effect as first calling socket_bind6 with IP address :: and port 0. so like, you're covered either way, king π«Ά
now, about scope_id β the meaning of it is dependent on the implementation and the IPv6 IP. on link-local IPv6 addresses it specifies the outgoing interface index. the name (e.g. "eth0") for a given interface index can be queried with getifname. and ngl, scope_id should normally be set to 0. periodt.
π RETURN VALUE π
socket_send6 returns 0 if the datagram was sent successfully. iconic. π
if not, it returns -1 and sets errno appropriately. π so like, check your errno, bestie, it's literally telling you what went wrong.
β¨ EXAMPLE β¨
here's the whole thing in action, no edits, exactly as written:
#include <libowfat/socket.h>
int s;
char ip[16];
uint16 p;
uint32 scope_id;
s = socket_tcp4();
socket_bind6(s,ip,p);
socket_send6(s,"hello, world",12,ip,p,scope_id);
look at her go π§ main character energy fr fr.
π SEE ALSO π
π heads up bestie:scope_idis implementation-dependent and you should normally just set it to0. don't be out here guessing at interface indices for fun.
and that's the whole page, gorgeous. this one's from the Library Functions Manual, filed under socket_send6(3) β same name top and bottom, cute symmetry, we love to see it. mwah π go send some datagrams responsibly.
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· 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 noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- 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