qlibs:(socket_tcp)
π socket_tcp π
Bestie, welcome to the qlibs:(socket_tcp) page β it's literally all about setting up TCP sockets, and we're gonna get you comfy with it. No cap. π«Ά
β¨ NAME β¨
socket_tcpβ setting up TCP sockets.
πΈ SYNTAX πΈ
Start with this include, okay?
#include "socket_if.h"
int socket_tcp4();
int socket_tcp6();
int socket_tcp();
π¦ DESCRIPTION π¦
Okay so here's the tea, function by function. π
socket_tcp4()β creates a non-blocking TCP/IPv4 stream socket and providing a file descriptor pointing to that socket.socket_tcp6()β creates a non-blocking TCP/IPv6 stream socket and providing a file descriptor pointing to that socket.socket_tcp()β creates a non-blocking IPv6 TCP/IP socket, callingsocket_tcp6()unless it can't bind to IPv6, and now facilitatingsocket_tcp4()in that case.
π₯ REMOTE CODES π₯
π¨ Vibe check on returns: all these routines return0except in case of failures, returning-1and settingerrnoappropriately, without allocating any resources.
π EXAMPLE π
This is the example, and yes we keep it exactly as it is because code is sacred:
#include <socket_if.h>
int t;
char localip[16];
char remoteip[16];
uint16 p;
if (ip6_isv4mapped(remoteip)) {
t = socket_tcp4();
socket_bind4(t,localip + 12,0);
} else {
t = socket_tcp6();
socket_bind6(t,localip,0,0);
}
socket_connect(s,remoteip,p,0);
π SEE ALSO π
Go read these too, bestie β they're iconic:
socket_if(3)socket_bind(3)socket_connect(3)socket_info(3)socket_recv(3)socket_send(3)socket_setup(3)socket_udp(3)
Sign-off: XOXO π β this footer moment says date 3 and source/version qlibs:(socket_tcp). Slay and goodbye, bestie! π
β¨
π¦ 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