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
V
Blog on different tools and technology or concept that useful for the begineer that start their jouney in software industry

Before moving to understand the TCP and UDP Let’s understand why we need this actually?

The Internet Needs Rules -

The Internet is not a magic or something where we send it goes like we see in the Ramayan or film. when the data is tranfer over the internet -

  • It travels through medium or path

  • it might follow different-different path

  • it may arrive late

  • it break data into small chunk

so to manage the whole ecosystem we need some rules or protocol (fancey-name) that every data or ecosystem that follow to transfer over internet.

In the OSI model at the transport layer two majorly protocol widle used that is TCP and UDP


What Are TCP and UDP?

TCP - Transmission Control Protocol

  • Connection oriented

  • Relible

  • follow Ordered

  • re-transmission

  • safe and Sequre

UDP - User Datagram Protocol

  • Connection less

  • fast

  • light-weight

  • Un-relible

  • may Data loss


When to Use TCP & UDP?

TCP -

  • Data is must not loss

  • Accuracy is critical

  • ordered of data packet matter

  • data relible is important

Example -

  • Payment Transection

  • Chat Application

  • login system

  • sending Email

  • opening websites

  • database communication

UDP -

  • Speed is matter over perfection

  • small loss is acceptable

  • Real-time communication is important

Example -

  • Video calls

  • Live Video streaming

  • online Gaming

  • Live Brodcast


What Is HTTP and Where It Fits?

HTTP stand for Hyper text transfer protocol. and it is application layer protocol not transport layer in OSI model.

HTTP protocol defines the follwing thing actually -

  • How request looks when we send

  • How response looks when recieved

  • Different Methode for sending request (GET, POST, PATCH, PUT, DELETE)

  • Information about the status code

  • Details about the Header

Relationship Between TCP and HTTP -

Actuallly HTTP run on the Top of the TCP because what happen when we type hashnode.com.

  • Browser create a standerd http request

  • HTTP request is send over TCP protocol

  • TCP will take care about the data transmission.

  • Server send the response

  • TCP will responsible for the safe delivery at client