9.10 sctp_recvmsg Function
Just like sctp_sendmsg, the sctp_recvmsg function provides a more user-friendly interface to the advanced SCTP features. Using this function allows a user to retrieve not only its peer's address, but also the msg_flags field that would normally accompany the recvmsg function call (e.g., MSG_NOTIFICATION, MSG_EOR, etc.). The function also allows the user to retrieve the sctp_sndrcvinfo structure that accompanies the message that was read into the message buffer. Note that if an application wishes to receive sctp_sndrcvinfo information, the sctp_data_io_event must be subscribed to with the SCTP_EVENTS socket option (ON by default). The sctp_recvmsg function takes the following form:
ssize_t sctp_recvmsg(int sockfd , void * msg , size_t msgsz , struct sockaddr * from , socklen_t * fromlen , struct sctp_sndrcvinfo * sinfo , int * msg_flags ); |
Returns: the number of bytes read, 1 on error |
On return from this call,
msg is filled with up to
msgsz bytes of data. The message sender's address is contained in
from , with the address size filled in the
fromlen argument. Any message flags will be contained in the
msg_flags argument. If the notification sctp_data_io_event has been enabled (the default), the sctp_sndrcvinfo structure will be filled in with detailed information about the message as well. Note that if an implementation maps the sctp_recvmsg to a recvmsg function call, the
flags field of the call will be set to 0.