SCTP_PEELOFF(3)

πŸ’– SCTP_PEELOFF(3) πŸ’–

okay bestie, welcome to the Linux Programmer's Manual page for sctp_peeloff β€” yes it's a real one, yes it's from the SCTP corner of the socket world, and yes we're gonna make it make sense. ✨


🌸 NAME 🌸

sctp_peeloff β€” Branch off an association into a separate socket.


πŸŽ€ SYNOPSIS πŸŽ€

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

int sctp_peeloff(int sd, sctp_assoc_t assoc_id);
int sctp_peeloff_flags(int sd, sctp_assoc_t assoc_id, unsigned flags);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like. sctp_peeloff takes an existing association assoc_id that's living on a one-to-many style socket sd, and branches it off into its own separate socket. and the new socket? it's a one-to-one style socket. it's giving glow-up, it's giving main character, it's giving "you get your own file descriptor now bestie." πŸ’…

why would you even want this, you ask? imagine your app has a bunch of sporadic message senders/receivers just chilling under the original one-to-many style socket, and then there's that one association carrying high volume data traffic like it's trying to be famous. you peel that one off into its own separate socket descriptor so it stops hogging the vibe. the sporadic ones stay put, the loud one gets its own room. periodt. πŸ”₯

sctp_peeloff_flags is the variant of sctp_peeloff where you can also pass flags describing how the newly peeled off socket should behave. right now the supported flags are:

  • SOCK_NONBLOCK β€” says the new socket should not block on io operations. no waiting around, no standing in line. ✨
  • SOCK_CLOEXEC β€” says the new socket should be closed when the owning process calls exec. it does not survive the exec, no cap. 🫢

⭐ RETURN VALUE ⭐

on success, you get back the new socket descriptor representing the branched-off association (yes, the original says "asociation", we're not fixing it, we're honoring it πŸ’€).

on error, -1 comes back and errno gets set appropriately. rude but informative.


πŸ’œ ERRORS πŸ’œ

  • EBADF β€” sd is not a valid descriptor. bestie that's not a socket that's a vibe void. 😭
  • EINVAL β€” the assoc id you passed is invalid, or the socket is a one-to-one style socket. (peeling off a one-to-one is not a thing, sorry.) πŸ™ˆ
  • ENOTSOCK β€” the argument is a descriptor for a file, not a socket. wrong door, wrong building, wrong genre. πŸ’€

🌈 NOTES 🌈

sctp_peeloff_flags is a linux specific variant of sctp_peeloff. it will compile on other systems, but using it there will result in an error return. so if you want portable code β€” and you do, bestie β€” use sctp_peeloff. 🧚


πŸ‘‘ SEE ALSO πŸ‘‘

sctp(7) sctp_bindx(3), sctp_connectx(3), sctp_sendmsg(3), sctp_sendv(3), sctp_send(3), sctp_recvmsg(3), sctp_recvv(3), sctp_getpaddrs(3), sctp_getladdrs(3), sctp_opt_info(3),


and that's the whole page, bestie. this one's stamped Linux 2.6, dated 2005-10-25, straight from the SCTP_PEELOFF(3) archives. go branch off an association and slay πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from