SCTP_RECVMSG(3)

πŸ“¦
version 1.0.21 Β· 3 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)
  • 14.5 Β· freebsd 14.5
  • 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_RECVMSG πŸ’–

okay bestie, welcome to sctp_recvmsg(3) β€” it's a Linux Programmer's Manual page and it's literally the moment your SCTP socket finally gets to receive. sit down, hydrate, let's go 🫢


✨ NAME ✨

sctp_recvmsg β€” Receive a message from a SCTP socket.

like. the whole vibe. it gets a message. from an SCTP socket. iconic behavior honestly πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

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

int sctp_recvmsg(int sd, void * msg, size_t len,
                 struct sockaddr * from, socklen_t * fromlen,
                 struct sctp_sndrcvinfo * sinfo, int * msg_flags);

there it is, no cap. that's the signature, copy it exactly, don't freestyle it πŸ’…


🌸 DESCRIPTION 🌸

so sctp_recvmsg is a wrapper library function β€” that's the key detail, it's a glow-up around the regular stuff β€” and you use it to receive a message from a socket while still getting all the advanced features of SCTP. the way that it gives you the fancy SCTP lore AND the message?? obsessed.

sd is the socket descriptor, and the message pointed to by msg with length len gets received on it. simple. slay.

now if from is not NULL, the source address of the message gets filled in for you. cute! and fromlen is a value-result parameter, which means it's a two-way street bestie β€” you initialize it to the size of the buffer associated with from, and then on return it's been modified to tell you the actual size of the address that got stored. she goes in one way and comes back different. main character energy fr fr ✨

sinfo is a pointer to a sctp_sndrcvinfo structure, and it gets filled in upon receipt of the message. it's giving "here's your receipt, queen."

msg_flags is a pointer to an integer that gets filled with any message flags, like MSG_NOTIFICATION or MSG_EOR. πŸŽ€

🚨 okay important one, listen up: the value of the msg_flags pointer should be initialized to 0 to avoid unexpected behavior. do not skip this. it's not a suggestion, it's a whole warning. also msg_flags is used as an input flags argument to the recvmsg function, so it's not just an output situation β€” it's both. initialize it to 0. periodt.

πŸ’œ RETURN VALUE πŸ’œ

on success, sctp_recvmsg returns the number of bytes received, or -1 if an error occurred. that's it, that's the whole report card 😭


πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, bestie, they're all in the family:


aaaand that's the page!! this one comes to you from Linux 2.6, dated 2005-10-25, filed under SCTP_RECVMSG(3) β€” yes she's vintage, yes she still eats πŸ’–βœ¨πŸŽ€ go forth and receive, you've got this πŸ¦‹πŸ’…πŸŒˆ

πŸ“¦ where this page comes from