SCTP_RECVV(3)

πŸ“¦
version 1.0.21 Β· 2 versions
  • 1.0.21 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 15.1 Β· freebsd 15.1
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– SCTP_RECVV πŸ’–

okay bestie, we're in the Linux manual section 3 today, and the star of the show is sctp_recvv β€” say it with me, "ess-see-tee-pee recv vee" πŸŽ€


✨ NAME ✨

sctp_recvv β€” Receive a message from a SCTP socket with an extensible way.

like, she's the fancy flexible version of receiving. slay.


🌸 SYNOPSIS 🌸

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/sctp.h>

int sctp_recvv(int sd, const struct iovec * iov, int iovlen,
               struct sockaddr * from, socklen_t * fromlen, void * info,
               socklen_t * infolen, unsigned int * infotype, int * flags);

copy that exactly, no typos, i'm watching πŸ‘€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so sctp_recvv is literally giving the SCTP stack an extensible way to pass up all the different SCTP attributes that come with a received message, straight to your application. iconic behavior honestly.

there are two types of attributes that can come back from this call:

  • the attribute of the received message, and
  • the attribute of the next message in the receive buffer.

you, the caller, enable the SCTP_RECVRCVINFO and SCTP_RECVNXTINFO socket options respectively to get these attributes. ✨

  • attributes of the received message come back in struct sctp_rcvinfo
  • attributes of the next message come back in struct sctp_nxtinfo

and if both options are enabled, both attributes come back using this structure right here:

struct sctp_recvv_rn {
  struct sctp_rcvinfo recvv_rcvinfo;
  struct sctp_nxtinfo recvv_nxtinfo;
};

no cap, that's the whole struct. πŸ’…


now let's break down the args, bestie, one by one:

  • sd is the socket descriptor. your little connection passport 🫢
  • iov is the scatter buffer, and only one user message is returned in this buffer. just the one, don't get greedy.
  • iovlen is the number of elements in iov.
  • from is a pointer to a buffer that gets filled with the sender of the received message's address. so you know who's talking to you πŸ’Œ
  • fromlen is an in/out parameter describing the from length.
  • info is a pointer to the buffer that holds the attributes of the received message, and the structure type of info is determined by the info_type parameter.
  • infolen is an in/out parameter describing the size of the info buffer.
  • on return, infotype is set to the type of the info buffer, and the currently defined values are... drumroll please πŸ₯

πŸŽ€ the infotype values πŸŽ€

  • SCTP_RECVV_NOINFO β€” if neither SCTP_RECVRCVINFO nor SCTP_RECVNXTINFO options are enabled, no attribute comes back at all. and if only the SCTP_RECVNXTINFO option is enabled but there's no next message in the buffer, again, no attribute comes back. in these cases, *info_type gets set to SCTP_RECVV_NOINFO. it's giving "nothing to see here" πŸ’€
  • SCTP_RECVV_RCVINFO β€” the type of info is struct sctp_rcvinfo, and the attribute relates to the received message. πŸ’–
  • SCTP_RECVV_NXTINFO β€” the type of info is struct sctp_nxtinfo, and the attribute relates to the next message in the receive buffer. this is the case when only the SCTP_RECVNXTINFO option is enabled and there is a next message in the buffer. peek-a-boo πŸ‘€
  • SCTP_RECVV_RN β€” the type of info is struct sctp_recvv_rn. the recvv_rcvinfo field is the attribute of the received message, and the recvv_nxtinfo field is the attribute of the next message in the buffer. this is the case when both SCTP_RECVRCVINFO and SCTP_RECVNXTINFO options are enabled and there's a next message in the receive buffer. best of both worlds, we love a combo 🌈

and last but not least:

  • flags is a pointer to an integer to be filled with any message flags (e.g., MSG_NOTIFICATION). πŸ“¬

⭐ RETURN VALUE ⭐

on success, sctp_recvv returns the number of bytes received, or -1 if an error occurred. that's it, that's the whole vibe check. 😭


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, bestie, knowledge is free πŸ’œ


🧚 little sign-off from your favorite Unix girlie: this page is from Linux 4.16, dated 2018-04-29, and it's SCTP_RECVV(3) β€” periodt. now go receive some messages, you've got this. πŸ’…βœ¨πŸŒΈ
πŸ“¦ where this page comes from