qlibs:(socket_recv)
π NAME π
okay bestie, welcome to the qlibs:(socket_recv) page β manual name folded in like a lil sticker, periodt β¨
socket_recv β receive UDP datagrams over IPv4/IPv6 connections.
β¨ SYNTAX β¨
include this header and this signature, no cap:
#include "socket_if.h"
int socket_recv(int s, const char *buf, unsigned int len,
const char ip[16], uint16 *port, uint32 *scope_id);
π DESCRIPTION π
okay so socket_recv reads len bytes starting at buf in a UDP datagram over the socket s. while it's doing that, it also hands you info about the remote IP address ip, the UDP port, and the perhaps scope_id of the receiving interface π«Ά
and here's the cute part: you can call socket_recv without calling socket_bind first. that has the effect as first calling socket_bind with IP address :: and port 0. literally no bind, still fine π
πΈ RETURN VALUE πΈ
socket_recv returns n, the number of bytes received β or otherwise -1 and sets errno appropriately. that's the whole vibe check π
π¦ EXAMPLE π¦
here's the example, keep it exact bestie:
#include <socket_if.h>
#include <ip.h>
int s;
char localip[16];
char remoteip[16];
uint16 p, port;
uint32 scope_id;
unsigned int len;
int r;
char buf[MTUSIZE+1];
s = socket_udp();
socket_bind_reuse(s,localip,p,0);
r = socket_recv(s,buf,len,remoteip,&port,&scope_id);
π SEE ALSO π
socket_if(3)socket_info(3)socket_bind(3)socket_connect(3)socket_send(3)socket_setup(3)socket_tcp(3)socket_udp(3)
okay that's the whole page, bestie! π«Ά cute lil footer sign-off: source/version is qlibs:(socket_recv), date/section is 3. go forth and receive those datagrams responsibly π
β¨
π¦ where this page comes from
- alpine 3.24: fehqlibs-doc 31-r0 Β· Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms