SCTP Programmer's Guide

SOCK_STREAM Indicates the creation of a one-to-one style socket.
IPPROTO_SCTP Specifies the type of the protocol.
The first syntax of the socket() socket API creates an endpoint that can use only IPv4
addresses, while the second syntax creates an endpoint, which can use both IPv6 and
IPv4 addresses.
The bind() Socket API
Applications use bind() to specify the local address with which an SCTP endpoint
must associate.
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, the endpoint must call listen(), after calling bind(). For information on
listen(), see “The listen() Socket API” (page 45).
Following is the syntax for the bind() 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 either be 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 bind()
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 binding with a
wildcard address. One of the addresses in the address set serves as the primary address
for the association. Thus, when an application calls bind() with the INADDR_ANY or
the IN6ADDR_ANY_INIT wildcard address, the multihoming feature is enabled in
SCTP.
The completion of the bind() process alone does not prepare the SCTP endpoint to
accept inbound SCTP association requests. When a listen() system call is performed
on the socket, the SCTP endpoint promptly rejects an inbound INIT request using an
ABORT flag.
44 SCTP Socket APIs