Skip to main content

Command Palette

Search for a command to run...

TCP vs UDP Protocol

Published
2 min read
TCP vs UDP Protocol
H

This is Harsh Mange, working as a Software Engineer - Backend at Argoid. I love building apps. Working on contributing to open-source projects and the dev community.

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are both protocols that are used to transfer data over the internet. Here are some key differences between the two:

  1. Connection-oriented vs connectionless

    TCP is a connection-oriented protocol, which means that it establishes a connection between two devices before data transfer begins. UDP is a connectionless protocol, which means that it does not establish a connection before data transfer and packets are simply sent without any confirmation.

  2. Reliability

    TCP is a reliable protocol, which means that it ensures that all data sent is received by the destination device in the correct order. This is done by using sequence numbers, acknowledgements, and retransmission of lost packets. UDP is an unreliable protocol, which means that packets may be lost or arrive out of order and it does not perform any error checking or retransmission.

  3. Speed

    UDP is faster than TCP since it does not have to establish a connection or perform error checking and retransmission. This makes it ideal for applications that require high-speed data transfer such as real-time gaming or video streaming.

  4. Usage

    TCP is used for applications where reliability is critical such as web browsing, email, and file transfer. UDP is used for applications where speed is more important than reliability such as video conferencing, online gaming, and live streaming.

Example

For example, when you visit a website using your web browser, TCP is used to establish a connection between your computer and the server hosting the website. TCP ensures that all the data is received in the correct order, and if any packets are lost, it requests them to be resent. On the other hand, when you are streaming a video on YouTube, UDP is used since speed is more important than reliability. If a few packets are lost or arrive out of order, it is not a big deal as the video will still continue playing.

More from this blog

Bit Fetch

97 posts

This is Harsh Mange, working as a Software Engineer at Travel Corporation of India (Thomas Cook Group). I love building apps. Working on contributing to open-source projects and the dev community.