SCTP_CONNECTX(3)
π SCTP_CONNECTX(3) β bestie's guide to connecting with ALL the addresses
okay so this is a page from the Linux Programmer's Manual, and it's about sctp_connectx, which is literally the main character of "connect to a whole squad of addresses at once". Sit down, grab a boba, we're doing this. π§β¨
β¨ NAME β¨
sctp_connectx β initiate a connection on an SCTP socket using multiple destination addresses.
like, plural. many. a whole group chat of addresses. no cap. π
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/sctp.h>
int sctp_connectx(int sd, struct sockaddr * addrs, int addrcnt,
sctp_assoc_t * id);
π DESCRIPTION π
so sctp_connectx initiates a connection to a set of addresses β they get passed in through the array called addrs β to/from the socket sd. and addrcnt is how many addresses are in that array, periodt.
if sd is an IPv4 socket, the addresses you pass must be IPv4 addresses. if sd is an IPv6 socket, the addresses you pass can be either IPv4 or IPv6 addresses. flexible queen behavior fr fr. π¦
addrs is a pointer to an array of one or more socket addresses. each address lives inside its appropriate structure (i.e. struct sockaddr_in or struct sockaddr_in6). the family of the address type must be used to distinguish the address length β that's not optional, bestie, that's the rules. and the caller specifies the number of addresses in the array with addrcnt.
id is a pointer to the association id and, if provided, will be set to the identifier of the newly created association. cute little output param, we love her. π
π₯ RETURN VALUE π₯
- success β
0is returned. slay. β¨ - failure β
-1is returned, anderrnois set appropriately. π
π ERRORS π
like, here's the whole drama list of things that can go wrong:
EBADFβsdis not a valid descriptor.ENOTSOCKβsdis a descriptor for a file, not a socket. bestie. that's a file. not a socket. πEFAULTβ error while copying in or out from the user address space.EINVALβ invalid port or address.EACCESβ the address is protected, and the user is not the super-user.EISCONNβ the socket is already connected. she's taken. πECONNREFUSEDβ no one listening on the remote address. ghosted fr. π»ETIMEDOUTβ timeout while attempting connection. the server may be too busy to accept new connections. note that for IP sockets the timeout may be very long when syncookies are enabled on the server. like, very long. pack a snack. πENETUNREACHβ network is unreachable.EADDRINUSEβ local address is already in use.EINPROGRESSβ the socket is non-blocking and the connection cannot be completed immediately. it is possible toselect(2)orpoll(2)for completion by selecting the socket for writing. afterselectindicates writability, usegetsockopt(2)to read theSO_ERRORoption at levelSOL_SOCKETto determine whether connect completed successfully (SO_ERRORis zero) or unsuccessfully (SO_ERRORis one of the usual error codes listed here, explaining the reason for the failure).EALREADYβ the socket is non-blocking and a previous connection attempt has not yet been completed. girl, patience. π§EAGAINβ no more free local ports or insufficient entries in the routing cache. forPF_INETsee thenet.ipv4.ip_local_port_rangesysctl inip(7)on how to increase the number of local ports.EAFNOSUPPORTβ the passed address didn't have the correct address family in itssa_familyfield.EACCES,EPERMβ the user tried to connect to a broadcast address without having the socket broadcast flag enabled or the connection request failed because of a local firewall rule.
ok important vibe check:EINPROGRESSandEALREADYaren't "you broke it" errors, they're "the plot is still unfolding" errors. handle them like a grown-up. π«Ά
π SEE ALSO π
sctp(7) sctp_bindx(3), sctp_sendmsg(3), sctp_sendv(3), sctp_send(3), sctp_recvmsg(3), sctp_recvv(3), sctp_peeloff(3), sctp_getpaddrs(3), sctp_getladdrs(3), sctp_opt_info(3),
and that's the whole page, bestie!! π this one's from Linux 2.6, dated 2005-10-25 β yeah she's vintage, she's an icon, she's still serving. mwah. πβ¨
π¦ where this page comes from
- alpine 3.22: lksctp-tools-doc 1.0.19-r5 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- alpine 3.23: lksctp-tools-doc 1.0.19-r5 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- alpine 3.24: lksctp-tools-doc 1.0.19-r5 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- arch rolling: lksctp-tools 1.0.21-1 Β· GPL-2.0-or-later AND LGPL-2.1-only
- centos-stream 10: lksctp-tools-devel 1.0.21-1.el10 Β· GPLv2 and GPLv2+ and LGPLv2 and MIT
- centos-stream 9: lksctp-tools-devel 1.0.19-2.el9 Β· GPLv2 and GPLv2+ and LGPLv2 and MIT
- centos-stream 9: lksctp-tools-devel 1.0.19-2.el9 Β· GPLv2 and GPLv2+ and LGPLv2 and MIT
- debian bookworm: libsctp-dev 1.0.19+dfsg-2 Β· GPL-2.0-or-later
- debian trixie: libsctp-dev 1.0.21+dfsg-1 Β· GPL-2.0-or-later
- fedora 43: lksctp-tools-devel 1.0.21-1.fc43 Β· GPL-2.0-or-later AND LGPL-2.0-only AND MIT
- fedora 43: lksctp-tools-devel 1.0.21-1.fc43 Β· GPL-2.0-or-later AND LGPL-2.0-only AND MIT
- fedora 44: lksctp-tools-devel 1.0.21-3.fc44 Β· GPL-2.0-or-later AND LGPL-2.0-only AND MIT
- fedora 44: lksctp-tools-devel 1.0.21-3.fc44 Β· GPL-2.0-or-later AND LGPL-2.0-only AND MIT
- nixos 26.05: lksctp-tools 1.0.21
- nixpkgs unstable: lksctp-tools 1.0.21
- opensuse-leap 16.0: lksctp-tools-devel 1.0.21-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: lksctp-tools-devel 1.0.21-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: lksctp-tools-devel 1.0.21-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: lksctp-tools-devel 1.0.21-160000.3.2 Β· LGPL-2.1-or-later
- ubuntu jammy: libsctp-dev 1.0.19+dfsg-1build1 Β· GPL-2.0-or-later
- ubuntu noble: libsctp-dev 1.0.19+dfsg-2build1 Β· GPL-2.0-or-later
- ubuntu questing: libsctp-dev 1.0.21+dfsg-1build1
- ubuntu resolute: libsctp-dev 1.0.21+dfsg-1build2 Β· GPL-2.0-or-later
- ubuntu stonking: libsctp-dev 1.0.21+dfsg-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms