SCTP Programmer's Guide

The send(), sendto(), recv(), and recvfrom() Socket Calls
Applications can use the send() and sendto() socket calls to transmit data to the
peer. The recv() and recvfrom() socket calls can be used to receive data from the
peer.
Following are the syntaxes for the send(), sendto(), recv(), and recvfrom()
socket calls, respectively:
ssize_t send(int sd, const void *msg, size_t len, int flags);
ssize_t sendto(int sd, const void *msg, size_t len, int flags,
const struct sockaddr *to, socklen_t tolen);
ssize_t recv(int sd, void *buf, size_t len, int flags);
ssize_t recvfrom(int sd, void *buf, size_t len, int flags,
struct sockaddr *from, socklen_t *fromlen);
where:
sd
Specifies the socket descriptor of an SCTP endpoint.
msg
Specifies the message to be sent.
len
Specifies the size of the message or the size of buffer.
to
Specifies one of the peer addresses of the association to be used to send
the message.
tolen
Specifies the size of the address.
buf
Specifies the buffer to store a received message.
from
Specifies the buffer to store the peer address used to send the received
message.
fromlen
Specifies the size of the from address.
flags
Contains flags affecting the message being sent.
The send(), sendto(), recv(), and recvfrom() calls provide access to only basic
SCTP protocol features. If a peer in an association uses multiple streams or sends
unordered data, these calls may not be adequate. As a result, it may deliver data in
unpredictable ways.
These calls do not allow the application to specify the stream on which a message must
be sent. SCTP uses stream 0 as the default stream to send data using send() and
sendto(). The recv() and recvfrom() calls return data from any stream. However,
the application cannot distinguish the different streams. As a result, data arrives without
any order. Similarly, if an application sends unordered data chunk, recv() and
recvfrom() do not provide any notification for the unordered data.
The message buffer buf in the send() and sendto() calls is a single message buffer.
If the caller wants to send a message that is composed of several buffers, the caller must
combine all the buffers, before calling send() and sendto(). Alternately, the caller
can use the sendmsg() call to send multiple buffers, without combining the buffers.
The recv() and recvfrom() calls cannot distinguish message boundaries.
You cannot use the send() and recv() calls in the case of one-to-many style sockets.
Common Socket Calls 55