Skip to main content

Command Palette

Search for a command to run...

TCP and UDP

Published
•1 min read•View as Markdown

What are TCP and UDP?

TCP → reliable, ordering of packets maintained, loss detection => Retransmission possible, Congestion control

TCP happens through 3 way handshake

UDP :-
Less reliable (not unreliable😅)
NO retransmission if data packets lost
very fast
no 3 way handshake.

Key differences between TCP and UDP

TCP is reliable and more safe but UDP is fast (the main key difference)

When to use TCP

When you want a secure connection between server and client. USE TCP.
When you want very high speed then use UDP.

Common real-world examples of TCP vs UDP

Real world examples :-

  1. TCP → Whatsapp chat → We definitely dont want my chats getting leaked to someone else.

  2. UDP → In game where latency matters like pubg, free fire etc. OR in live matches of IPL where its not possible to establish a connection between so many users in lakhs.

What is HTTP and where it fits

HTTP is a protocol which tells how data will flow from server to client.

Relationship between TCP and HTTP

TCP tells that how the data will be sent and HTTP is what data will be sent. Thus, http has various requests like GET, POST, PUT etc. so http and tcp goes hand in hand