Advanced · Module 8 · Lesson 5 of 11
Connectionless Datagrams: UDP Sockets, Framing, and Packet Loss
Master connectionless UDP networking with sendto and recvfrom, preserve message boundaries, build application-level framing, and diagnose packet loss.
By the end you can
- Instantiate and operate datagram sockets using socket, SOCK_DGRAM, sendto, and recvfrom
- Differentiate message-boundary preservation from continuous byte streams
- Optimize datagram routing and peer filtering by binding endpoints with connect
- Construct application-level framing headers with sequence numbers and checksums to detect packet loss
Builds on High-Performance Event Multiplexing: Linux epoll Architecture.
01 · A question first
Why does sending two separate 100-byte chunks over TCP merge into a single 200-byte read, while over UDP each chunk is delivered as an atomic message or lost entirely? And why does calling connect() on a UDP socket skip the network handshake completely?
Make a guess before you read on.
02 · The idea
Members only
Unlock the full lesson
This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.
What's inside
- Start with the problem
- How the idea works
- Complete Working Example: UDP Client-Server Ping
- The "Connected" UDP Socket
- Application-Level Framing and Reliability
- Why it is correct
- What it costs
- Pitfalls and variations
03 · Practice
Asked in interviews
Something wrong with this lesson? Report a problem