TCP Working: 3-Way Handshake & Reliable Communication

Learning web development in public. Writing simple, real-world explanations about web development concepts. Helping beginners understand why things work, not just how.
Search for a command to run...

Learning web development in public. Writing simple, real-world explanations about web development concepts. Helping beginners understand why things work, not just how.
No comments yet. Be the first to comment.
Every day, millions of users upload photos, videos, stories, and reels to Instagram. From a user's perspective, the process appears simple: select media, apply filters, add a caption, and tap "Post."
Building Offline-First Messaging Apps: How Messages Work Without Internet Modern messaging applications have transformed the way people communicate. Whether it's chatting with friends, collaborating w
In this article we'll explore about the Expo Router and React Navigation and answer which one to use in 2026. If you build mobile apps using React Native, one thing becomes obvious very quickly: Navig

Modern mobile apps are no longer just a collection of screens connected together. Apps like Instagram, WhatsApp, Uber, and Netflix operate at massive scale with millions of users, real time systems, o
In this article we'll be exploring react.js and the things of react.js that makes it popular and stand out among other libraries ( no fight over library vs framework ). We'll go through: What problem

Shkaai
68 posts
Imagine you want to send an important message to your friend.
You shout it from one building to another and hope they hear it.
What could go wrong?
Message may not reach
Parts may be missed
Words may arrive in wrong order
You don’t even know if the other person heard it
That’s exactly what would happen on the internet without rules.
The internet is not a single wire.
Data travels through routers, cables, wireless signals, and multiple networks.
Loss, delay, and disorder are normal, not exceptions.
So the big question becomes:
How do two computers talk reliably on such an unreliable network?
That’s where TCP comes in.
TCP (Transmission Control Protocol) exists for one simple reason:
“Make sure data reaches correctly, completely, and in the right order.”
TCP does not care about speed first.
It cares about correctness.
Whenever you:
Load a website
Login to an app
Download a file
Make a payment
TCP is quietly working in the background, making sure nothing breaks.
TCP is polite.
It does not start sending data immediately.
First, it wants to make sure:
The other side is alive
The other side is ready
Both sides agree to talk
This preparation phase is called the 3-Way Handshake.
Think of TCP handshake like starting a phone call ☎️.
The client starts by saying:
“Hey, I want to talk to you. Are you available?”
This message is called SYN (Synchronize).
At this point:
No data is sent
Only intention is expressed
The server replies:
“Yes, I hear you. I’m ready too.”
This reply contains:
SYN → “I also want to talk”
ACK → “I heard your request”
Now both sides know:
The connection path works
Messages can travel both ways
Finally, the client replies:
“Perfect. Let’s begin.”
This ACK confirms everything.
Now the connection is established.
Only after this step does actual data transfer begin.

Client → SYN → Server
Client ← SYN + ACK ← Server
Client → ACK → Server
Once this finishes:
👉 TCP connection is open
👉 Data can flow safely
Now that the connection is open, data starts flowing.
But TCP doesn’t send data blindly.
Every chunk of data is tagged with a sequence number.
Think of sequence numbers like page numbers in a book 📖.
If pages arrive:
Out of order → TCP rearranges them
Missing → TCP asks again
This ensures:
Data integrity
Correct order
No confusion
After receiving data, the receiver responds:
“I got everything up to this point.”
This response is called an ACK (Acknowledgement).
ACKs help TCP:
Confirm delivery
Detect loss
Decide what to resend
TCP never assumes.
It always waits for confirmation.
Packet loss is normal on the internet.
TCP handles this calmly.
If:
ACK doesn’t arrive
Or data arrives incomplete
TCP says:
“Okay, let me resend that part.”
This process is called retransmission.
To the application (browser, API, user):
Everything still looks smooth
Errors are hidden
That’s why TCP feels reliable.
Because of:
Handshake
Sequence numbers
Acknowledgements
Retransmissions
TCP guarantees:
No silent data loss
No broken messages
No corrupted transfers
This reliability is why TCP is used for:
HTTP
HTTPS
APIs
Emails
File transfers
Just like TCP starts politely, it also ends politely.
When communication is done, one side says:
“I’m done sending data.”
This message is called FIN.
The other side replies:
“Okay, I acknowledge that.”
That’s ACK.
Both sides agree to close the connection cleanly.
No sudden hang-ups.
No confusion.
TCP’s reliability comes at a cost:
Extra checks
Confirmations
Retransmissions
But for most applications:
Correct data is more important than fast data.
That tradeoff is intentional.
TCP is not just a protocol.
It is a discipline.
It teaches the internet how to:
Communicate clearly
Recover from mistakes
Maintain trust between machines
The 3-Way Handshake is TCP’s way of saying:
“Let’s agree before we talk.”
Once you understand this, networking stops feeling mysterious and starts feeling logical.