SOCKET_FASTOPEN_CONNECT6(3)
β¨ socket_fastopen_connect6 β the NAME bit β¨
okay so bestie, this is socket_fastopen_connect6, and it lives in the Library Functions Manual (section 3, obviously π
). Its whole entire job? make a TCP connection and send some data. That's it. That's the girl. π
πΈ SYNTAX πΈ
first you gotta pull in the header, no cap:
#include <libowfat/socket.h>
and here's the function signature, character for character, don't @ me:
ssize_t socket_fastopen_connect6(int s,
const char ip[16],uint16 port,uint32 scope_id,
const char* buf,size_t len);
π DESCRIPTION π
so socket_fastopen_connect6 tries to make a connection from TCP socket s to TCP port port on IP address ip. and if that pops off? then it tries to send len bytes from buf. simple. iconic. π¦
now here's the tea β β the difference between this and just calling socket_connect6 and then write is that on platforms that support TCP Fast Open, socket_fastopen_connect6 will send that first data packet in the third packet of the TCP handshake, which saves one whole useless ACK packet in network traffic. we love efficiency, we love not wasting packets, periodt. π₯
heads up though: this is only useful for protocols where the client sends the first bytes. if your protocol doesn't do that, this ain't it, bestie π
and the manpage literally says socket_connect6 may return β yes it says socket_connect6, not this one, iykyk, i don't make the rules π β so here's what that return situation looks like:
>=0β the connection succeeded and this many bytes were sent β¨-1β and it setserrnotoerror_inprogressorerror_wouldblock, which means the socket is non-blocking-1β and it setserrnoto something else, which means the connection failed (and it failed immediately, if the socket is non-blocking)
when a background connection succeeds or fails, s becomes writable β you can use socket_connected to see whether the connection actually succeeded. and if the connection failed, socket_connected returns 0 and sets errno appropriately. keeping receipts, always π«Ά
once a TCP socket is connected, you can use the read and write system calls to transmit data. the classics, still slaying π
alsoooo you can call socket_connect6 without calling socket_bind6 first β it has the same effect as calling socket_bind6 with IP address :: and port 0. no prep needed, main character energy π
π§ EXAMPLE π§
here's the whole vibe, verbatim:
#include <libowfat/socket.h>
int s;
char ip[16];
uint16 p;
uint32 scope_id;
s = socket_tcp6b();
socket_bind6(s,ip,p);
socket_fastopen_connect6(s,ip,p,scope_id,"hello",5);
look at her go ππ
β SEE ALSO β
go read these next, they're all in the friend group:
okay that's the whole page, no notes π huge shoutout to the Library Functions Manual for hosting this banger, and to socket_fastopen_connect6(3) herself β the page title, the footer, the moment, the icon π bye bestie, go send some bytes π¦β¨
π¦ 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