SCTP_SENDMSG(3)
π SCTP_SENDMSG(3) π
okay bestie, gather round, because this one is a library function from the Linux Programmer's Manual and it's literally the glow-up version of sendmsg(2) for SCTP girlies. no cap.
β¨ NAME β¨
sctp_sendmsg β send a message from a SCTP socket. that's it. that's the whole job. sending. slay. π
π SYNOPSIS π
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/sctp.h>
int sctp_sendmsg(int sd, const void * msg, size_t len,
struct sockaddr *to, socklen_t tolen,
uint32_t ppid, uint32_t flags,
uint16_t stream_no, uint32_t timetolive,
uint32_t context);
like, look at that parameter list. it's giving "i have options and i'm not afraid to use them." β¨
πΈ DESCRIPTION πΈ
so sctp_sendmsg is a wrapper library function, which is fancy-speak for "we made it easy for you." you use it to send a message from a socket while also unlocking the advanced features of SCTP, because regular sending is boring and we don't do boring here. π
here's the breakdown, bestie:
sdβ the socket descriptor, aka where the message is coming from. the origin story.msgβ a pointer to the message itself, andlenis how long that message is.toβ the destination address of the message, withtolenbeing the length of that destination address.stream_noβ identifies the stream number the application wants to send this message to. pick your lane, queen. πflagsβ a parameter composed of a bitwise OR of the values listed below. yes, OR them together. stack those flags like accessories.
π₯ the flags (aka the whole personality) π₯
SCTP_UNORDEREDβ this flag requests un-ordered delivery of the message. no queue, no waiting, just vibes. πSCTP_ADDR_OVERβ in the one-to-many style, this asks the SCTP stack to override the primary destination address with the address specified into. main character address energy only. πSCTP_ABORTβ setting this causes the specified association to abort by sending an ABORT message to the peer (one-to-many style only). the ABORT chunk will contain an error cause'User Initiated Abort'with cause code12, and the cause specific information of this error cause is provided inmsg. dramatic? yes. necessary? also yes. π«’SCTP_EOFβ setting this invokes the SCTP graceful shutdown procedure on the specific association (one-to-many style only). leaving the group chat politely, with a proper goodbye. πSCTP_SENDALLβ if set, this will cause a one-to-many style socket to send the message to all associations that are currently established on this socket. for the one-to-one style socket, this flag has no effect. group message, no notes. πSCTP_SACK_IMMEDIATELYβ this flag lets the application set the I bit of the last DATA chunk when sending each user message, to make sure the corresponding SACK can be sent by the peer without delay. impatient? no, efficient. βSCTP_PR_SCTP_{TTL|RTX|PRIO}β one of these 3pr_policiescan be used through this flag, with itspr_valueset in thetimetoliveparameter for this message. and note:sctp_sendv(3)with infotypeSCTP_SENDV_PRINFOalso works for PR-SCTP. options on options, iykyk. π¦
π§ the rest of the params, because they matter too π§
timetoliveβ specifies the time duration in milliseconds. the sending side will expire the message if the message has not been sent to the peer within this time period. a value of0indicates that no timeout should occur on this message. it also works as thepr_valueif theflagsparameter is set topr_policy. so it's multitasking. iconic.ppidβ an opaque unsigned value that is passed to the remote end along with the message. it's a little gift, an opaque little gift. πcontextβ a 32 bit opaque value that is passed back to the upper layer along with the undelivered message if an error occurs on the send of the message. so if things go wrong, at least you get your context back. closure, fr fr. π
π RETURN VALUE π
on success, sctp_sendmsg returns the number of bytes sent, or -1 if an error occurred. that's it. that's the whole mood. either you ate, or you got -1. π₯
π SEE ALSO π
the besties, the sisters, the whole crew:
sctp(7)sctp_bindx(3)sctp_connectx(3)sctp_sendv(3)sctp_send(3)sctp_recvmsg(3)sctp_recvv(3)sctp_peeloff(3)sctp_getpaddrs(3)sctp_getladdrs(3)sctp_opt_info(3)
lowkey reminder bestie: theSCTP_ABORT,SCTP_EOFandSCTP_ADDR_OVERflags are one-to-many style only, andSCTP_SENDALLliterally does nothing on a one-to-one style socket. read the flags before you send, or you'll be sending into the void. π
okay and that's the page!! this was the Linux 2.6 version, dated 2004-10-25, so yeah she's vintage but she still serves. mwah, go send some messages responsibly πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- arch rolling: lksctp-tools 1.0.21-1 Β· GPL-2.0-or-later AND LGPL-2.1-only
- centos-stream 10: lksctp-tools-devel 1.0.21-1.el10 Β· GPLv2 and GPLv2+ and LGPLv2 and MIT
- debian trixie: libsctp-dev 1.0.21+dfsg-1 Β· GPL-2.0-or-later
- fedora 43: lksctp-tools-devel 1.0.21-1.fc43 Β· GPL-2.0-or-later AND LGPL-2.0-only AND MIT
- fedora 43: lksctp-tools-devel 1.0.21-1.fc43 Β· GPL-2.0-or-later AND LGPL-2.0-only AND MIT
- fedora 44: lksctp-tools-devel 1.0.21-3.fc44 Β· GPL-2.0-or-later AND LGPL-2.0-only AND MIT
- fedora 44: lksctp-tools-devel 1.0.21-3.fc44 Β· GPL-2.0-or-later AND LGPL-2.0-only AND MIT
- nixos 26.05: lksctp-tools 1.0.21
- nixpkgs unstable: lksctp-tools 1.0.21
- opensuse-leap 16.0: lksctp-tools-devel 1.0.21-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: lksctp-tools-devel 1.0.21-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: lksctp-tools-devel 1.0.21-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: lksctp-tools-devel 1.0.21-160000.3.2 Β· LGPL-2.1-or-later
- ubuntu questing: libsctp-dev 1.0.21+dfsg-1build1
- ubuntu resolute: libsctp-dev 1.0.21+dfsg-1build2 Β· GPL-2.0-or-later
- ubuntu stonking: libsctp-dev 1.0.21+dfsg-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms