If you strip away the screens and the code, the internet is basically just a giant game of "pass the parcel." You have data on one computer, and you need to get it to another computer.
But here is the problem: the internet is chaotic. Cables break, signals get weak, and routers get overwhelmed. If you just throw data into the void, it might get lost.
To fix this, we have protocols (fancy name for Rules) that decide how we send that data. The two big players are TCP and UDP.
They are the yin and yang of networking. One cares about perfection; the other cares about speed.
TCP (Transmission Control Protocol)
TCP (Transmission Control Protocol) is built on one philosophy: Reliability. It guarantees that every single byte you send arrives exactly as intended.
How It Actually Works (The Three-Way Handshake): Before any data moves, TCP forces the two computers to agree to a conversation. This is called the Three-Way Handshake.
1. SYN: Your computer sends a "Synchronize" packet to the server ("Hello? Are you there?").
2. SYN-ACK: The server replies with "Synchronize-Acknowledge" ("Yes, I am here and ready").
3. ACK: Your computer
replies "Acknowledge" ("Great, I’m starting now").
Think of this like a Certified Courier Service. You don't just throw a box on a truck. You call the courier, they confirm the pickup, and you sign the paperwork before the truck even moves.
Data Transmission (Sequencing): Once the connection is open, TCP chops your data into small packets. Crucially, it assigns a Sequence Number to each one (Packet 1, Packet 2, Packet 3).
If Packet #2 gets lost in transit? The receiver notices the gap between #1 and #3 and refuses to process the data. It sends a signal back saying, "I am missing #2!" The sender then retransmits just that missing piece.
This constant checking makes TCP heavy and slightly slower, but it ensures your emails and websites never load with missing text.
UDP (User Datagram Protocol)
UDP (User Datagram Protocol) is the opposite. It is Connectionless. It doesn’t care about handshakes, and it doesn’t care if the data arrives.
How It Actually Works: UDP skips the handshake entirely. There is no SYN or ACK. It just takes your data, wraps it in a tiny header (much smaller than TCP’s), and blasts it onto the wire immediately.
If a packet drops? UDP doesn’t care. It doesn't look back. It has already moved on to the next packet.
Think of UDP like a Live Video Broadcast. The reporter is talking fast. If the signal glitches and you miss a word, the reporter doesn't stop, rewind, and say it again. They just keep talking. By the time you realize you missed something, the moment is gone.
Why use UDP?
In things like Online Gaming or Video Calls, speed is more important than perfection. If you are playing COD or CS:GO and a packet containing your enemy's location gets lost, you don't want the game to freeze for 2 seconds while TCP tries to recover it. You want the game to keep moving to the current location. A glitch is better than a lag spike.
Where Does HTTP Fit?
This is the part that confuses most beginners. You hear "HTTP" and "TCP" and assume they are two different ways to do the same thing.
They aren't. They are two different parts of the same package.
To understand this, imagine you are sending a letter to a friend.
1. HTTP is the Letter (The Content) You sit down and write a note: "Dear Server, please send me the home page. Sincerely, Browser." This is HTTP (Hypertext Transfer Protocol). It is just text. It defines what you want to say ("GET /index.html"). But here is the catch: a piece of paper cannot fly through the air on its own. If you just throw the letter out the window, it goes nowhere.
2. TCP is the Envelope (The Delivery) To actually send the letter, you have to fold it up and put it inside an Envelope. On the outside of the envelope, you write the address (IP Address), the apartment number (Port), and you pay for a tracking number (Sequence Number) to ensure it arrives. This is TCP.
This is why HTTP doesn't need to worry about lost data. If the mail truck crashes and the envelope is destroyed, TCP (the postal service) notices the tracking number is missing and sends a new envelope. HTTP (the letter writer) doesn't even know there was a crash. It just waits for the reply.
Top comments (0)