UDPLITE(4)

πŸ’– UDPLITE(4) β€” bestie edition πŸ’–

okay so. sit down, grab a strawberry something, because we're talking about udplite β€” the Lightweight User Datagram Protocol β€” and this is genuinely one of my fave little gremlins in the kernel. this page lives in the Kernel Interfaces Manual, and yes it's giving ✨niche but iconic✨. iykyk.


🌸 NAME 🌸

udplite β€” Lightweight User Datagram Protocol πŸ¦‹


✨ SYNOPSIS ✨

like, the whole vibe in code form:

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

int
socket(AF_INET, SOCK_DGRAM, IPPROTO_UDPLITE);

so you include those three headers β€” sys/types.h, sys/socket.h, and netinet/udplite.h β€” and then you make the socket with AF_INET, SOCK_DGRAM, and IPPROTO_UDPLITE. no cap, that's it. πŸŽ€


πŸ’… DESCRIPTION πŸ’…

okay bestie, here's the tea β˜•. the UDP-Lite protocol provides a partial checksum which allows corrupted packets to be transmitted to the receiving application. the way that lower-layer protocols would normally just yeet a damaged datagram into the void? UDP-Lite is like, "no, actually, let them have it." 😌

and this has advantages for some types of multimedia transport that may be able to make use of slightly damaged datagrams, rather than having them discarded by lower-layer protocols. some apps would genuinely rather have a slightly crunchy packet than no packet at all. main character behaviour fr fr 🫢

UDP-Lite supports a number of socket options which can be set with setsockopt(2) and tested with getsockopt(2) β€” and here they are, the whole squad:

  • UDPLITE_SEND_CSCOV β€” this option sets the sender checksum coverage. a value of zero indicates that all sent packets will have full checksum coverage. a value of 8 to 65535 limits the checksum coverage of all sent packets to the value given. πŸ’«
  • UDPLITE_RECV_CSCOV β€” this option is the receiver-side analogue. a value of zero instructs the kernel to drop all received packets not having full checksum coverage. a value of 8 to 65535 instructs the kernel to drop all received packets with a partial checksum coverage smaller than the value specified. πŸ’€ (yes, the kernel is petty and it will absolutely discard things. it said "vibe check failed.")

😭 ERRORS 😭

a socket operation may fail with one of the following errors returned. ngl these are the little landmines, so let's go:

  • [EISCONN] β€” when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected. like bestie, it's already connected, stop trying to connect again πŸ™ˆ
  • [ENOTCONN] β€” when trying to send a datagram, but no destination address is specified, and the socket has not been connected. you can't send a message with no address and no connection, that's just shouting into the void πŸ’Œ
  • [ENOBUFS] β€” when the system runs out of memory for an internal data structure. the machine is full, it said no more πŸ“
  • [EADDRINUSE] β€” when an attempt is made to create a socket with a port which has already been allocated. that port is TAKEN, find your own πŸ’…
  • [EADDRNOTAVAIL] β€” when an attempt is made to create a socket with a network address for which no network interface exists. that address is a ghost, there's no interface there πŸ‘»

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, they're the friends of this page:

getsockopt(2), recv(2), send(2), socket(2) ✨


and that's the whole page, bestie. this beauty comes to you from Debian, dated October 1, 2014 β€” an elder, but a legend, and we respect her πŸ’œ. slay, go write some partial checksums. periodt. πŸŽ€πŸŒˆβ­

πŸ“¦ where this page comes from