SCTP_GETLADDRS(3)
π SCTP_GETLADDRS π
okay bestie, welcome to the Linux Programmer's Manual, SCTP_GETLADDRS(3) edition β this is the one where you find out every single address your socket is locally bound to. it's giving β¨address reveal partyβ¨ and honestly? obsessed. πΈ
β¨ NAME β¨
sctp_getladdrs β returns all locally bound addresses on a socket. yes that's literally the whole job. she's focused. π
π¦ SYNOPSIS π¦
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/sctp.h>
int sctp_getladdrs(int sd, sctp_assoc_t assoc_id,
struct sockaddr **addrs);
void sctp_freeladdrs(struct sockaddr *addrs);
look at those two. they're a package deal, fr fr. one gets you the goods, the other cleans up the mess. π«Ά
π DESCRIPTION π
so. sctp_getladdrs returns all locally bound addresses on a socket. when it comes back, addrs will point to a dynamically allocated packed array of sockaddr structures β and each one is the appropriate type for its local address, no cap. π
π real talk tho: the caller should usesctp_freeladdrsto free that memory. and the in/out parameteraddrsmust not be NULL. like, that's a hard no. don't do it.
if sd is an IPv4 socket, the addresses you get back will be all IPv4 addresses. simple. clean. iconic.
if sd is an IPv6 socket, the addresses you get back can be a mix of IPv4 or IPv6 addresses. she contains multitudes, okay? π
now for the association tea β:
- for one-to-many style sockets,
idspecifies the association to query π - for one-to-one style sockets,
idis ignored. she said "not my business" π
and if the id field is set to 0, then the locally bound addresses are returned without regard to any particular association. just vibes. all of them. πΈ
lastly: sctp_freeladdrs frees all the resources allocated by sctp_getladdrs. that's her whole personality and she does it well. β¨
β RETURN VALUE β
- on success β
sctp_getladdrsreturns the number of local addresses bound to the socket. a little count, a little slay. π₯ - if the socket is unbound β
0is returned and the value of*addrsis undefined π - on error β
sctp_getladdrsreturns-1and the value of*addrsis undefined π
π«Ά just to be clear bestie: undefined means undefined. don't go reading *addrs and expecting a gift. that's not the vibe check you want to fail.
π SEE ALSO π
sctp(7)sctp_bindx(3)sctp_connectx(3)sctp_sendmsg(3)sctp_sendv(3)sctp_send(3)sctp_recvmsg(3)sctp_recvv(3)sctp_peeloff(3)sctp_getpaddrs(3)sctp_opt_info(3)
the whole friend group, assembled. go read them too, iykyk. π
and that's the page!! this one came straight out of Linux 2.6, dated 2005-10-25 β yes she's an elder but she's still serving π β mwah, love u, go free your addrs π«Άβ¨
π¦ 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