SCTP Programmer's Guide

sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
or
sd = socket(PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP);
where:
SOCK_SEQPACKET
Indicates the creation of a one-to-one or one-to-many style
socket.
IPProto_SCTP
Specifies the type of the protocol.
PF_INET
Specifies the IPv4 domain.
PF_INET6
Specifies the IPv6 domain.
The first syntax of socket() creates an endpoint that can use only IPv4 addresses,
while the second syntax creates an endpoint that can use both IPv6 and IPv4 addresses.
The bind() Socket API
Applications use bind() to specify the local address to which an SCTP endpoint must
associate.
An SCTP endpoint can be associated with multiple addresses. The sctp_bindx()
API enables applications to associate with multiple addresses. For information on
sctp_bindx(), see “The sctp_bindx() SCTP Socket API” (page 61). These addresses,
associated with a socket, are eligible transport addresses for the endpoint to send and
receive data. The endpoint also presents these addresses to its peers during the
association initialization process. To accept new associations on the socket, applications
must call listen(), after calling bind(). For information on listen(), see “The
listen() Socket API” (page 45).
Following is the syntax for the bind() socket API:
ret = bind(int sd, struct sockaddr *addr, socklen_t addrlen);
where:
sd Represents the socket descriptor returned by the socket() call.
addr
Represents the address structure (struct sockaddr_in or struct
sockaddr_in6).
addrlen
Represents the size of the address structure.
If sd is an IPv4 socket, the address passed must be an IPv4 address. If sd is an IPv6
socket, the address passed can be either an IPv4 or an IPv6 address.
Applications cannot call bind() multiple times to associate multiple addresses to an
endpoint. After the first call to bind(), all the subsequent calls will return an error.
If addr is specified as a wildcard (INADDR_ANY for an IPv4 address, or
IN6ADDR_ANY_INIT or in6addr_any for an IPv6 address), the operating system
associates the endpoint with an optimal address set of the available interfaces.
If a bind() call is not called before a sendmsg() call that initiates a new association,
the endpoint picks a transient port and chooses an address set that is equivalent to
50 SCTP Socket APIs