qlibs:(socket_send)
π qlibs:(socket_send) π
okay bestie, welcome to qlibs:(socket_send) β the manual page for sending data over a UDP socket, and we are gonna make it make sense π
π ROUTINES π
socket_sendβ sending data over a UDP socket π
π¦ SYNTAX π¦
#include "socket_if.h"
int socket_send4(int s,const char *buf,unsigned int len,
const char ip[4],uint16 port);
int socket_send6(int s,const char *buf,unsigned int len,
const char ip[16],uint16 port,uint32 scope_id);
int socket_send(int s,const char *buf,unsigned int len,
const char ip[16],uint16 port,uint32 scope_id);
β¨ DESCRIPTION β¨
So here's the vibe: socket_send4 sends len bytes starting at buf in a UDP datagram over the socket s to UDP port port on IPv4 address ip. Slay π
socket_send6 sends len bytes starting at buf in a UDP datagram over the socket s to UDP port port on IPv6 address ip and perhaps using scope_id as the outging interface π
For link-local IPv6 (LLU) addresses, scope_id specifies the outgoing interface index. socket_id can be queried for the given name of the interface (e.g. "eth0") by means of socket_getifidx. scope_id should normally be set to 0 except for link local IPv6 addresses π¦
socket_send sends len bytes starting at buf in a UDP datagram over the socket s to UDP port port on IP address ip and perhaps using scope_id as the outging interface β¨
And here's the iconic part: you can call socket_send* without calling socket_bind* π«Ά This has the effect as first calling socket_bind4 with IP address 0.0.0.0 and port 0 or socket_bind6 with IP address :: and port 0. no cap.
π₯ RETURN VALUE π₯
socket_send* returns n, the number of bytes transmitted in the datagram. If not, it returns -1 and sets errno appropriately π
πΈ EXAMPLE πΈ
#include <socket_if.h>
int s;
char ip[4];
uint16 p;
s = socket_udp();
socket_bind(s,ip,p);
socket_send(s,"hello, world",12,ip,p,0);
π SEE ALSO π
socket_if(3)socket_info(3)socket_bind(3)socket_connect(3)socket_recv(3)socket_setup(3)socket_tcp(3)socket_udp(3)
xoxo, stay slay β this has been qlibs:(socket_send), section 3, periodt π
π«Ά
π¦ 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