<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Siddhant Bansal</title>
    <description>The latest articles on DEV Community by Siddhant Bansal (@siddhant_bansal_8ee33e455).</description>
    <link>https://dev.to/siddhant_bansal_8ee33e455</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3095753%2Fe77df1e2-6c9f-4be1-b66a-e637b6a1074e.png</url>
      <title>DEV Community: Siddhant Bansal</title>
      <link>https://dev.to/siddhant_bansal_8ee33e455</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siddhant_bansal_8ee33e455"/>
    <language>en</language>
    <item>
      <title>Understanding TCP 3-Way Handshake: The Heartbeat of Internet Communication</title>
      <dc:creator>Siddhant Bansal</dc:creator>
      <pubDate>Sat, 03 May 2025 11:25:54 +0000</pubDate>
      <link>https://dev.to/siddhant_bansal_8ee33e455/understanding-tcp-3-way-handshake-the-heartbeat-of-internet-communication-jeb</link>
      <guid>https://dev.to/siddhant_bansal_8ee33e455/understanding-tcp-3-way-handshake-the-heartbeat-of-internet-communication-jeb</guid>
      <description>&lt;h2&gt;
  
  
  🔗 Understanding the TCP 3-Way Handshake:
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;TCP 3-Way Handshake&lt;/strong&gt; is a fundamental process that establishes a reliable connection between two devices over a &lt;strong&gt;TCP/IP&lt;/strong&gt; network. It involves three steps: &lt;strong&gt;SYN&lt;/strong&gt; (Synchronize), &lt;strong&gt;SYN-ACK&lt;/strong&gt; (Synchronize-Acknowledge), and &lt;strong&gt;ACK&lt;/strong&gt; (Acknowledge). During the handshake, the client and server exchange initial sequence numbers and confirm the connection establishment.  &lt;/p&gt;




&lt;h2&gt;
  
  
  What Is TCP?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TCP (Transmission Control Protocol)&lt;/strong&gt; is a foundational internet protocol designed to:&lt;br&gt;
✅ Deliver data &lt;strong&gt;reliably&lt;/strong&gt; (no lost or duplicated packets)&lt;br&gt;&lt;br&gt;
✅ Ensure &lt;strong&gt;in-order&lt;/strong&gt; delivery (packets arrive in the order they were sent)&lt;br&gt;&lt;br&gt;
✅ Provide &lt;strong&gt;error-checking&lt;/strong&gt; (detect and fix corrupted data)&lt;/p&gt;

&lt;p&gt;Unlike &lt;strong&gt;UDP&lt;/strong&gt; (which just throws data out, hoping it arrives), TCP carefully sets up, manages, and closes connections.&lt;/p&gt;




&lt;h2&gt;
  
  
  What’s Inside a TCP Segment?
&lt;/h2&gt;

&lt;p&gt;Before understanding the handshake, it’s useful to know what each TCP packet (called a &lt;strong&gt;segment&lt;/strong&gt;) contains:&lt;br&gt;
The header of a &lt;strong&gt;TCP segment&lt;/strong&gt; can range from &lt;strong&gt;20-60 bytes&lt;/strong&gt;. 40 bytes are for options. If there are no options, a header is 20 bytes else it can be of upmost 60 bytes. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnreg21eovtmk5z501rp9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnreg21eovtmk5z501rp9.png" alt="TCP Header" width="767" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Header fields:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Field&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Source Port&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;16-bit number identifying the sending application’s port (e.g., your browser’s port)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Destination Port&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;16-bit number identifying the receiving application’s port (e.g., web server port 80)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sequence Number&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;32-bit number marking the &lt;strong&gt;first byte&lt;/strong&gt; in this segment; helps reorder packets and track delivery&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Acknowledgment Number&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;32-bit number showing the &lt;strong&gt;next expected byte&lt;/strong&gt;; confirms successful receipt of earlier data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Header Length (HLEN)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;4-bit number indicating header size (in 4-byte words); minimum 5 (20 bytes), maximum 15 (60 bytes)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Control Flags&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;6 key flags controlling the connection: URG, ACK, PSH, RST, SYN, FIN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Window Size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Communicates how much data the receiver can accept at once (flow control)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Checksum&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Ensures data integrity; calculated by sender, verified by receiver&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Urgent Pointer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;If URG is set, points to urgent data requiring immediate processing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Key Flags Overview:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SYN&lt;/strong&gt; → Start a connection (Synchronize)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ACK&lt;/strong&gt; → Acknowledge received data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FIN&lt;/strong&gt; → Finish/close the connection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RST&lt;/strong&gt; → Reset the connection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PSH&lt;/strong&gt; → Push data immediately to the application&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;URG&lt;/strong&gt; → Urgent data included&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step-by-Step: TCP 3-Way Handshake
&lt;/h2&gt;

&lt;p&gt;The handshake &lt;strong&gt;synchronizes sequence numbers&lt;/strong&gt; and ensures both client and server are ready to communicate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsu6j747f9qb1u01rrfb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsu6j747f9qb1u01rrfb.png" alt="Image description" width="589" height="666"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;1. SYN → Client → Server&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The client sends:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SYN flag&lt;/strong&gt; set&lt;/li&gt;
&lt;li&gt;Picks an initial &lt;strong&gt;Sequence Number&lt;/strong&gt; (e.g., 1000)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🗣 &lt;strong&gt;Client says:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;"I want to connect. Here’s my starting number (1000)."&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;2. SYN-ACK → Server → Client&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The server responds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SYN + ACK flags&lt;/strong&gt; set&lt;/li&gt;
&lt;li&gt;Picks its own &lt;strong&gt;Sequence Number&lt;/strong&gt; (e.g., 5000)&lt;/li&gt;
&lt;li&gt;Acknowledges the client’s number (&lt;code&gt;ACK = 1001&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🗣 &lt;strong&gt;Server says:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;"Got your request (ack 1001). My number is 5000."&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;3. ACK → Client → Server&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The client confirms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ACK flag&lt;/strong&gt; set&lt;/li&gt;
&lt;li&gt;Acknowledges the server’s number (&lt;code&gt;ACK = 5001&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🗣 &lt;strong&gt;Client says:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;"Got your number (ack 5001). Let’s start!"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connection is now fully established&lt;/strong&gt; — data can start flowing both ways.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real-World Example
&lt;/h2&gt;

&lt;p&gt;Imagine Alice wants to chat with Bob:&lt;/p&gt;

&lt;p&gt;1️⃣ &lt;strong&gt;Alice:&lt;/strong&gt; “Hi Bob! I want to start a conversation. Here’s message #1000.” (SYN)&lt;br&gt;&lt;br&gt;
2️⃣ &lt;strong&gt;Bob:&lt;/strong&gt; “Hi Alice! Got your hello (ack 1001). My next message is #5000.” (SYN-ACK)&lt;br&gt;&lt;br&gt;
3️⃣ &lt;strong&gt;Alice:&lt;/strong&gt; “Great! Got your hello (ack 5001). Let’s talk!” (ACK)&lt;/p&gt;

&lt;p&gt;Now they’re ready to exchange full conversations.&lt;/p&gt;




&lt;h2&gt;
  
  
  Puzzle Piece Analogy for Sequence Numbers
&lt;/h2&gt;

&lt;p&gt;Imagine you and your friend are mailing puzzle pieces back and forth:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You (client)&lt;/strong&gt; send piece &lt;strong&gt;#1000&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Your friend (server) says:
“Okay, I got &lt;strong&gt;#1000&lt;/strong&gt;, send me &lt;strong&gt;#1001&lt;/strong&gt; next.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Meanwhile, your friend sends you &lt;strong&gt;#5000&lt;/strong&gt;, and you say:&lt;br&gt;&lt;br&gt;
“Okay, got it, send &lt;strong&gt;#5001&lt;/strong&gt; next.”&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Each side tracks its own sequence counter&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You track &lt;strong&gt;what you’re sending&lt;/strong&gt; and &lt;strong&gt;what you expect back&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;They track &lt;strong&gt;what they’re sending&lt;/strong&gt; and &lt;strong&gt;what they expect back&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why Are Sequence and Acknowledgment Numbers Important?
&lt;/h2&gt;

&lt;p&gt;These numbers:&lt;br&gt;
✅ Ensure &lt;strong&gt;no data is lost or duplicated&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
✅ Allow both sides to &lt;strong&gt;reassemble packets&lt;/strong&gt; correctly, even if they arrive out of order&lt;br&gt;&lt;br&gt;
✅ Provide a &lt;strong&gt;reliable stream&lt;/strong&gt; over an unreliable network&lt;/p&gt;

&lt;p&gt;Without them, TCP wouldn’t know if pieces were missing or mixed up.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;3-Way Handshake&lt;/strong&gt; runs &lt;strong&gt;once per connection&lt;/strong&gt; (unless restarted).&lt;/li&gt;
&lt;li&gt;Sequence numbers &lt;strong&gt;keep increasing&lt;/strong&gt; with each data exchange.&lt;/li&gt;
&lt;li&gt;TCP underpins reliable services like &lt;strong&gt;websites, emails, video streaming&lt;/strong&gt;, and &lt;strong&gt;file transfers&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Summary Table
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Step&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Who&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Action&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1 → SYN&lt;/td&gt;
&lt;td&gt;Client&lt;/td&gt;
&lt;td&gt;Requests connection; sends initial sequence number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2 → SYN-ACK&lt;/td&gt;
&lt;td&gt;Server&lt;/td&gt;
&lt;td&gt;Acknowledges client; sends its own sequence number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3 → ACK&lt;/td&gt;
&lt;td&gt;Client&lt;/td&gt;
&lt;td&gt;Confirms receipt; connection fully established&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>computerscience</category>
      <category>interview</category>
      <category>learning</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>TCP vs UDP: Which One Should You Choose for Your Next App?</title>
      <dc:creator>Siddhant Bansal</dc:creator>
      <pubDate>Sun, 27 Apr 2025 09:13:50 +0000</pubDate>
      <link>https://dev.to/siddhant_bansal_8ee33e455/tcp-vs-udp-which-one-should-you-choose-for-your-next-app-5683</link>
      <guid>https://dev.to/siddhant_bansal_8ee33e455/tcp-vs-udp-which-one-should-you-choose-for-your-next-app-5683</guid>
      <description>&lt;p&gt;Recently, while diving deeper into &lt;strong&gt;Computer Networks&lt;/strong&gt;, I stumbled upon a really interesting question!&lt;br&gt;
 &lt;em&gt;"&lt;/em&gt;&lt;em&gt;When should we use TCP and when should we use UDP?&lt;/em&gt;&lt;em&gt;"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;At first, it felt simple — two protocols, just pick one, right?&lt;br&gt;&lt;br&gt;
But as I explored more, I realized this question is not just technical — it’s very &lt;strong&gt;practical&lt;/strong&gt; and even might &lt;strong&gt;frequently be asked in interviews&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;So I thought, why not share this learning in a way that’s easy to understand for everyone?  &lt;/p&gt;

&lt;h2&gt;
  
  
  First Things First: Where Do TCP and UDP Fit?
&lt;/h2&gt;

&lt;p&gt;Before we compare TCP and UDP, it's important to know &lt;strong&gt;where they belong&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Both TCP and UDP are part of the &lt;strong&gt;Transport Layer&lt;/strong&gt; of the &lt;strong&gt;TCP/IP model&lt;/strong&gt; .&lt;br&gt;&lt;br&gt;
The TCP/IP model is a fundamental framework that guides how data moves across networks like the Internet ensuring reliable communication between devices.&lt;/p&gt;

&lt;p&gt;The layers are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Application Layer (Presentation + Session)&lt;/strong&gt; — Your apps (browser, mail client, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transport Layer&lt;/strong&gt; — Responsible for &lt;strong&gt;delivering&lt;/strong&gt; data (hello, TCP and UDP!)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network Layer&lt;/strong&gt; — Deals with routing (IP addresses, paths).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network Access Layer (Data Link + Physical)&lt;/strong&gt; — Physical sending of data (Wi-Fi, Ethernet, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfxbwwcn1q8n3hhmib0f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfxbwwcn1q8n3hhmib0f.png" alt="Image description" width="583" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Understanding this made me realize:- &lt;br&gt;
TCP and UDP are like two different &lt;strong&gt;delivery systems&lt;/strong&gt; sitting right between your app and the network!&lt;/p&gt;

&lt;h2&gt;
  
  
  Then, What Exactly is TCP?
&lt;/h2&gt;

&lt;p&gt;As I dug further, I found that &lt;strong&gt;TCP&lt;/strong&gt; stands for &lt;strong&gt;Transmission Control Protocol&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What makes TCP special:&lt;br&gt;
🔹 &lt;strong&gt;Reliable Data Transfer&lt;/strong&gt;&lt;br&gt;
TCP/IP ensures that data sent from one device reaches another accurately and reliably without loss or corruption.&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Divides Data into Packets&lt;/strong&gt;&lt;br&gt;
To maintain accuracy during transmission, TCP/IP breaks large data into smaller packets, which can be easily transmitted over networks.&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Reassembles Data at Destination&lt;/strong&gt;&lt;br&gt;
At the receiver's end, TCP/IP reassembles the packets back into the original message, ensuring the information remains intact.&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Supports Multiple Physical Media&lt;/strong&gt;&lt;br&gt;
TCP/IP is flexible — it can work over a wide variety of physical media and network technologies (like Ethernet, Wi-Fi, fiber optics, etc.).&lt;/p&gt;

&lt;p&gt;🔹&lt;strong&gt;Real-world Internet Backbone&lt;/strong&gt;&lt;br&gt;
TCP/IP is the foundation of the real-world internet, making it possible for devices across the globe to communicate, regardless of the underlying hardware.&lt;/p&gt;

&lt;p&gt;🔹&lt;strong&gt;No Strict Physical Layer Specification&lt;/strong&gt;&lt;br&gt;
Unlike some models, TCP/IP does not bind itself to one specific Physical Layer. This allows it to adapt easily to different hardware setups.&lt;/p&gt;

&lt;p&gt;Imagine making a &lt;strong&gt;phone call&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
You first dial, wait for the person to pick up, confirm they're listening — &lt;strong&gt;only then&lt;/strong&gt; you start speaking.&lt;br&gt;&lt;br&gt;
That's TCP for us.&lt;/p&gt;

&lt;p&gt;🔵 &lt;strong&gt;Real-world Examples of TCP:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Web browsing (HTTP/HTTPS)&lt;/strong&gt; — You can’t afford missing chunks of a webpage!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Emails (SMTP/IMAP/POP3)&lt;/strong&gt; — You need your full email, not half of it!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File transfers (FTP)&lt;/strong&gt; — Every file must be accurate.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  And What About UDP?
&lt;/h2&gt;

&lt;p&gt;On the other hand, &lt;strong&gt;UDP&lt;/strong&gt; stands for &lt;strong&gt;User Datagram Protocol&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
This one is a &lt;strong&gt;connectionless&lt;/strong&gt; protocol.&lt;/p&gt;

&lt;p&gt;Here’s what makes UDP different:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No need to establish a formal connection, data is sent &lt;strong&gt;immediately&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;No guarantee that the data will arrive in order (or even arrive at all).&lt;/li&gt;
&lt;li&gt;It’s &lt;strong&gt;faster&lt;/strong&gt; because there’s no overhead of connection or rechecking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of UDP like &lt;strong&gt;sending a letter by post&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
You drop it into a mailbox and hope it reaches, but you don’t wait for a "delivered" message.&lt;/p&gt;

&lt;p&gt;🟠 &lt;strong&gt;Real-world Examples of UDP:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live video streaming (YouTube Live, Twitch)&lt;/strong&gt; — A few lost frames? No big deal!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Voice calls (Zoom, Skype)&lt;/strong&gt; — Speed matters more than a perfect connection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Online gaming (PUBG, Fortnite)&lt;/strong&gt; — Instant updates are crucial.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Breaking It Down: TCP vs UDP
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;TCP&lt;/th&gt;
&lt;th&gt;UDP&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Connection&lt;/td&gt;
&lt;td&gt;Connection-Oriented&lt;/td&gt;
&lt;td&gt;Connectionless&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reliability&lt;/td&gt;
&lt;td&gt;High (Reliable Delivery)&lt;/td&gt;
&lt;td&gt;Low (Best-Effort Delivery)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed&lt;/td&gt;
&lt;td&gt;Slower&lt;/td&gt;
&lt;td&gt;Faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Packet Ordering&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Overhead&lt;/td&gt;
&lt;td&gt;More (acknowledgments, retransmissions)&lt;/td&gt;
&lt;td&gt;Less (minimal control)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Common Use Cases&lt;/td&gt;
&lt;td&gt;Websites, Emails, File Transfers&lt;/td&gt;
&lt;td&gt;Gaming, Live Video, Calls&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6tzlytf7x63xsep3151.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6tzlytf7x63xsep3151.png" alt="Image description" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Now, The Big Question: Which One Should You Choose?
&lt;/h2&gt;

&lt;p&gt;After exploring, here’s the conclusion I came to:&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Use TCP when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need &lt;strong&gt;accuracy and reliability&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Example: Banking apps, payment gateways, websites, file downloads.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Use UDP when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need &lt;strong&gt;speed&lt;/strong&gt; and &lt;strong&gt;can tolerate minor data loss&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Example: Online games, video calls, real-time streaming.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;TCP = Reliability over Speed&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;UDP = Speed over Reliability&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;While learning about TCP and UDP, I realized something important, &lt;br&gt;
Choosing the right protocol is not just about technical aspects; it's about &lt;strong&gt;user experience&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Imagine losing a few words during a live speech is tolerable.&lt;br&gt;&lt;br&gt;
But losing 20% of your online banking transaction data? Absolutely not!&lt;/p&gt;

&lt;p&gt;Both TCP and UDP have their own strengths and weaknesses.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Your choice depends completely on your app’s needs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I hope this deep dive helped you learn something new today!  &lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>programming</category>
      <category>softwareengineering</category>
      <category>interview</category>
    </item>
  </channel>
</rss>
