Advanced · Module 8 · Lesson 1 of 11
Socket Foundations: Berkeley Sockets, Address Structures, and TCP Handshakes
Master BSD socket APIs, configure IPv4 sockaddr_in structs, convert network byte endianness, and trace the TCP 3-way handshake across kernel socket queues.
By the end you can
- Instantiate stream sockets and bind endpoints using socket, sockaddr_in, and bind
- Transition passive listening sockets into connection queues using listen and accept
- Convert host integer representations to big-endian network byte order using htons and htonl
- Trace TCP 3-way handshake packet exchanges (SYN, SYN-ACK, ACK) to socket queue states
Builds on High-Throughput Worker Pools and Task Queues.
01 · A question first
Why does sending the port integer 8080 across a network socket connect to port 36895 on a remote host? And why does accept() allocate an entirely new file descriptor instead of returning the listening socket you passed to it?
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: Echo Server and Client
- Why it is correct
- What it costs
- Pitfalls and variations
- Where it is used
03 · Practice
Asked in interviews
Something wrong with this lesson? Report a problem