sctp_getladdrs
() Function
The sctp_getladdrs
() function returns all locally bound addresses on a socket. The syntax for the sctp_getladdrs
() function
is as follows:
int sctp_getladdrs(sock, id, **addrs); int sock, sctp_assoc_t id, void **addrs;
When the sctp_getladdrs
() function returns successfully, the value of addrs
points to a dynamically allocated packed array of sockaddr
structures. The sockaddr
structures are of the appropriate type for each local address. The calling application uses the sctp_freeladdrs
() function to free the memory. The value of the addrs
parameter must not be NULL.
If the socket referenced by the sd
parameter is an IPv4 socket, the sctp_getladdrs
() function returns IPv4 addresses. If the socket referenced by the sd
parameter is an IPv6 socket, the sctp_getladdrs
() function returns a mix of IPv4 or IPv6 addresses as appropriate.
When the sctp_getladdrs
() function is invoked for a one-to-many sockets model, the value of the id
parameter specifies the association to query. The sctp_getladdrs
() function ignores the id
parameter when the function is operating on a one-to-one socket.
When the value of the id
parameter is zero, the sctp_getladdrs
() function returns locally bound addresses without regard to any particular association. When the sctp_getladdrs
() function returns successfully, it reports the number of local addresses bound to the socket. If the socket is unbound, the sctp_getladdrs
() function returns 0 and the value of *addrs
is undefined. If an error occurs, the sctp_getladdrs
() function returns -1 and the value of *addrs
is undefined.