Skip to main content

Command Palette

Search for a command to run...

TCP vs UDP: When to Use What, and How TCP Relates to HTTP

Published
2 min read
TCP vs UDP: When to Use What, and How TCP Relates to HTTP
K

I am a problem solver and a full-stack developer. I love to write and share my knowledge. My wish is to learn and help others learn at the same time. Hoping to make a difference in the tech world.

TCP and UDP

TCP stands for Transmission Control Protocol

UDP stands for User Datagram Protocol

Both of these protocols work to transport data packets from sender to receiver.

Both TCP and UDP are in the Transport layer of the OSI Model

Key differences between TCP and UDP

TCPUDP
reliableunreliable
maintains orderdoes not maintain order
has loss detection capabilityNo loss detection
Re transmission occurs on failureNo retransmission
Supports congestion controlNo congestion control
SlowFast

When to use TCP

Use TCP when:

  • Data loss is not allowed

  • Security must not be tampered

  • Data Integrity must be maintained

  • Speed is not important

Zoomed view

When to use UDP

Use UDP when:

  • Data loss is negotiable

  • High speed data transmission is required

  • Delays are not allowed

User Datagram Protocol - UDP - GeeksforGeeks

Real World Examples of TCP and UDP

TCP:

  • Emails

  • Messages

  • Online banking

UDP:

  • Video Conferencing

  • Online gaming

  • Live streaming

What is HTTP and where it fits

HTTP stands for Hyper Text Transfer Protocol. It is in the Application layer of the OSI Model.

The http server lives in port 80.

Think like HTTP is the goods to be transported and the TCP/UDP are the roads which helps to transport it effectively.