TCP
What is it?
TCP is a core internet protocol that delivers data reliably and in order between two computers, making sure nothing is lost or jumbled.
Explain like I'm 5
Why was it created?
Networks drop and reorder packets. TCP was created to give applications a dependable, ordered stream on top of an unreliable network.
Where is it used?
- Web (HTTP/HTTPS) traffic
- Email and file transfer
- Database connections
- Most reliable internet communication
Why should developers care?
Most internet traffic — web, email, APIs — rides on TCP, so understanding it underpins all networking knowledge.
How does it work?
TCP opens a connection with a handshake, splits data into numbered segments, acknowledges what's received, retransmits anything lost, and reorders segments so the application gets a clean, ordered stream.
Real-world example
Loading a web page opens a TCP connection that guarantees the page's bytes arrive complete and in order, even if some packets are lost in transit.
Common use cases
- Reliable data transfer
- Web and API communication
- File and email transfer
- Any case where every byte must arrive
Advantages
- Reliable, ordered delivery
- Handles retransmission automatically
- Controls congestion
- Universally supported
Disadvantages
- More overhead and latency than UDP
- Connection setup costs time
- Not ideal for real-time streaming where speed beats completeness
When should you use it?
When every byte must arrive correctly and in order.
When should you avoid it?
For latency-critical real-time data (video, games) where UDP's speed is preferred.
Alternatives
Related terms
Interview questions
Beginner
- What does TCP guarantee?
- How does TCP differ from UDP?
Intermediate
- What is the TCP three-way handshake?
- What is an acknowledgement?
Senior
- How does TCP congestion control work?
- Why might QUIC be preferred over TCP?
Common misconceptions
- "TCP and IP are the same" — IP routes packets; TCP adds reliability on top of IP.
- "TCP is always best" — for real-time media, UDP's lower latency often wins.
Fun facts
- TCP stands for Transmission Control Protocol.
- It's so often paired with IP that the combo is just called TCP/IP.
Timeline
- 1981 — TCP standardized as a core internet protocol
Learning resources
Quick summary
TCP is the protocol that delivers data reliably and in order across the internet, underpinning the web, email, and most traffic.
Cheat sheet
- Reliable, ordered delivery
- Handshake + acknowledgements
- Retransmits lost data
- Heavier but dependable (vs UDP)