SCTP Programmer's Guide

7. sctp_setpaddrs()
8. recvmsg() or sctp_recvmsg()
9. sendmsg() or sctp_sendmsg()
10. sctp_peeloff()
11. close()
A client in the one-to-many style API uses the following call sequence to set up an
association with a server, and to request services from that server:
1. socket()
2. sendmsg() or sctp_sendmsg()
3. recvmsg() or sctp_recvmsg()
4. close()
By default, all the associations connected to an endpoint are represented with a single
socket. Each association is assigned an association ID (of type uint32_t
sctp_assoc_t), so that an application can use it to differentiate between different
associations. Applications can also use the sendto() call to set up an association.
However, an application cannot use the sendto() call to send data to an established
association, because the association ID cannot be specified in the sendto() call.
When an association ID is assigned to an SCTP association, SCTP must not reuse the
ID until the application explicitly terminates the association. The resources belonging
to that association are not freed until the association terminates. This is similar to the
close() call on a normal socket. The only difference between a normal socket and a
one-to-many socket is the availability of the SCTP_AUTOCLOSE option in the
one-to-many socket. When the SCTP_AUTOCLOSE option is set in a one-to-many socket,
an application can reuse the association ID assigned to the association once the
association terminates automatically. Applications that use this option must ensure
that they do not send data to an incorrect peer endpoint, because the association ID is
being reused.
A server or client can branch off an existing one-to-many association into a separate
socket. When an association is branched off to a separate socket, the branched off socket
is completely separated from the original socket. All subsequent control and data
operations on that association must be done through the new socket. For example, the
close() operation on the original socket does not terminate associations that have
been branched off to a different socket.
For more information on the one-to-many style socket APIs, see the subsequent
subsections and “SCTP-Specific Socket APIs” (page 61).
The socket() Socket API
The socket() socket API is used to create a socket descriptor that represents an SCTP
endpoint.
Following is the syntax for the socket() socket API:
Different Socket API Styles 49