sctp_bindx
() Function
int sctp_bindx(sock, *addrs, addrcnt, flags); int sock, void *addrs, int addrcnt, int flags;
The sctp_bindx
() function manages addresses on an SCTP socket. If the sock
parameter is an IPv4 socket, the addresses passed to the sctp_bindx
() function must be IPv4 addresses.
If the sock
parameter is an IPv6 socket, the addresses passed to the sctp_bindx
() function can be either IPv4 (in IPv4–mapped address format) or IPv6 addresses. When the address that is passed to the sctp_bindx
() function is INADDR_ANY
or IN6ADDR_ANY
, the socket binds to all available addresses. Bind the SCTP endpoint with the bind
.
If the sock
parameter is an IPv4 socket, *addrs should be an array of sockaddr_in
structures containing IPv4 addresses. If sock is an IPv6 socket, *addrs should be an array of sockaddr_in6
structures containing IPv6 or IPv4-mapped IPv6 addresses. The addrcnt
is the number of array elements in addrs
. The family of the address type is used with addrcnt
to determine the size of the array.
If the addresses are IPv6 addresses, they are contained in sockaddr_in6
structures. The address type's family distinguishes the address length. The caller specifies the number of addresses in the array with the addrcnt
parameter.
The sctp_bindx
() function returns 0 on success. The sctp_bindx
() function returns -1 on failure and sets the value of errno
to the appropriate error code.
If the same port is not given for each socket address, the sctp_bindx
() function fails and sets the value of errno
to EINVAL
.
The flags
parameter is formed from performing the bitwise OR operation on zero or more of the following currently defined flags:
-
SCTP_BINDX_ADD_ADDR
-
SCTP_BINDX_REM_ADDR
SCTP_BINDX_ADD_ADDR
directs SCTP to add the given addresses to the association. SCTP_BINDX_REM_ADDR
directs SCTP to remove the given addresses from the association. The two flags are mutually exclusive. If both are given, the sctp_bindx
() fails and sets the value of errno
to EINVAL
.
The caller should add or remove addresses one at a time. If an error occurs, and a list of addresses has been used, it is not possible for the caller to find the address that caused the error. Adding or removing addresses one at a time helps the caller resolve this issue.
A caller may not remove all addresses from an association. The sctp_bindx
() function rejects such an attempt by failing and setting the value of errno
to EINVAL
. An application can use sctp_bindx(SCTP_BINDX_ADD_ADDR)
to associate additional addresses with an endpoint after calling the bind
() function. An application can use sctp_bindx(SCTP_BINDX_REM_ADDR)
to remove addresses associated with a listening socket. After using sctp_bindx(SCTP_BINDX_REM_ADDR)
to remove addresses, accepting new associations will not reassociate the removed address. If the endpoint supports dynamic address, using SCTP_BINDX_REM_ADDR
or SCTP_BINDX_ADD_ADDR
sends a message to the peer to change the peer's address lists. Adding and removing addresses from a connected association is optional functionality. Implementations that do not support this functionality return EOPNOTSUPP
.
If the address family is not AF_INET
or AF_INET6
, the sctp_bindx
() function fails and returns EAFNOSUPPORT
. If the file descriptor passed to the sctp_bindx
() in the sock
parameter is invalid, the sctp_bindx
() function fails and returns EBADF
.