SCTP Programmer's Guide

binding with a wildcard address. One of the addresses in the address set serves as the
primary address for the association. This automatically enables the multi-homing
feature of SCTP.
The listen() Socket API
An application uses listen() to indicate that a socket is ready to accept new
associations.
Following is the syntax for the listen() socket API:
int listen(int sd, int backlog);
where:
sd
Specifies the socket descriptor of the endpoint.
backlog
Defines the number of connections in the listen queue.
By default, one-to-many style sockets do not accept new associations. If applications
that use one-to-many style socket APIs call the accept() API to accept new
associations, SCTP returns the EOPNOTSUPP error to the application. In the one-to-many
style socket APIs, new associations are accepted automatically and notifications of the
new associations are delivered using the recvmsg() API with the
SCTP_ASSOC_CHANGE event (if these notifications are enabled). A client in a
one-to-many association does not call listen(). Therefore, clients can be assured that
the only associations on the socket are the associations that are actively initiated. On
the contrary, a server or a peer-to-peer socket in a one-to-many connection always
accepts new associations. Therefore, an application running on a server using a
one-to-many style API must be prepared to handle new associations from unwanted
peers.
The SCTP_ASSOC_CHANGE event provides the association ID for a new association. If
applications want to use the association ID as input for other socket calls, they must
ensure that the SCTP_ASSOC_CHANGE event is enabled (it is enabled by default).
The sendmsg() and recvmsg() Socket APIs
An application uses sendmsg() and recvmsg() calls to transmit data to and receive
data from its peer.
ssize_t sendmsg(int sd, const struct msghdr *message, int flags);
ssize_t recvmsg(int sd, struct msghdr *message, int flags);
where:
sd
Specifies the socket descriptor.
message Specifies the pointer to the msghdr structure, which contains a single user
message and the ancillary data.
flags
Contains flags that affect messages that are being sent and received.
Different Socket API Styles 51