<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TCP Handshake & Reliable Communication]]></title><description><![CDATA[TCP Handshake & Reliable Communication]]></description><link>https://devesh10.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 22:51:54 GMT</lastBuildDate><atom:link href="https://devesh10.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[TCP Working: 3-Way Handshake & Reliable Communication]]></title><description><![CDATA[Introduction: What Happens to Data Without Rules?
Imagine you send a WhatsApp message, but:

You don’t know if the message was delivered

Messages arrive in the wrong order

Some messages disappear in between


Annoying, right?
If the internet worked...]]></description><link>https://devesh10.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://devesh10.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</guid><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[devesh gaynar]]></dc:creator><pubDate>Sat, 31 Jan 2026 17:41:08 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-introduction-what-happens-to-data-without-rules">Introduction: What Happens to Data Without Rules?</h2>
<p>Imagine you send a WhatsApp message, but:</p>
<ul>
<li><p>You don’t know if the message was delivered</p>
</li>
<li><p>Messages arrive in the wrong order</p>
</li>
<li><p>Some messages disappear in between</p>
</li>
</ul>
<p>Annoying, right?</p>
<p>If the internet worked like this, then <strong>websites, APIs, online banking — everything would fail</strong>.</p>
<p>This exact problem is solved by <strong>TCP</strong>.</p>
<hr />
<h2 id="heading-what-is-tcp-and-why-is-it-needed">What is TCP and Why Is It Needed?</h2>
<p>TCP (Transmission Control Protocol) is a <strong>transport protocol</strong> that makes sure:</p>
<ul>
<li><p>Data reaches the correct destination</p>
</li>
<li><p>Data arrives in the correct order</p>
</li>
<li><p>Data arrives completely</p>
</li>
</ul>
<p>Simple goal of TCP:</p>
<p><strong>“Reliable communication, no guessing.”</strong></p>
<hr />
<h2 id="heading-problems-tcp-is-designed-to-solve">Problems TCP Is Designed to Solve</h2>
<p>Without TCP, these problems would happen:</p>
<ul>
<li><p>Data loss</p>
</li>
<li><p>Duplicate data</p>
</li>
<li><p>Wrong order of data</p>
</li>
<li><p>No delivery confirmation</p>
</li>
</ul>
<p>TCP handles all of this <strong>automatically</strong>, without user involvement.</p>
<hr />
<h2 id="heading-what-is-the-tcp-3-way-handshake">What is the TCP 3-Way Handshake?</h2>
<p>Before sending data, TCP first <strong>creates a connection</strong>.<br />This process is called the <strong>3-Way Handshake</strong>.</p>
<p>Meaning:</p>
<p><strong>Both sides confirm they are ready before data transfer starts.</strong></p>
<hr />
<h2 id="heading-3-way-handshake-explained">3-Way Handshake Explained</h2>
<p>Think of a conversation between a <strong>client</strong> and a <strong>server</strong>.</p>
<h3 id="heading-step-1-syn">Step 1: SYN</h3>
<p>Client says:</p>
<blockquote>
<p>“Hello Server, can we talk?” (SYN)</p>
</blockquote>
<h3 id="heading-step-2-syn-ack">Step 2: SYN-ACK</h3>
<p>Server replies:</p>
<p>“Yes, I’m ready. Are you ready too?” (SYN + ACK)</p>
<h3 id="heading-step-3-ack">Step 3: ACK</h3>
<p>Client replies:</p>
<p>“Yes, I’m ready. Let’s start.” (ACK)</p>
<p>Connection is now established.</p>
<p><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQxMu6s4FTLoLdZ8saYjU9GBqbraRILbN26kA&amp;s" alt="TCP 3-way handshake and port scanning" /></p>
<hr />
<h2 id="heading-how-data-transfer-works-in-tcp">How Data Transfer Works in TCP</h2>
<p>TCP breaks data into <strong>small packets</strong>.</p>
<p>Each packet contains:</p>
<ul>
<li><p><strong>Sequence number</strong> (to maintain order)</p>
</li>
<li><p><strong>ACK number</strong> (for confirmation)</p>
</li>
</ul>
<p>The receiver says:</p>
<p>“Packet #5 received, send the next one.”</p>
<hr />
<h2 id="heading-how-tcp-ensures-reliability-order-and-accuracy">How TCP Ensures Reliability, Order, and Accuracy</h2>
<p>TCP guarantees:</p>
<ul>
<li><p><strong>Reliability:</strong> Lost packets are resent</p>
</li>
<li><p><strong>Order:</strong> Sequence numbers keep data in order</p>
</li>
<li><p><strong>Accuracy:</strong> Without ACK, data is not considered delivered</p>
</li>
</ul>
<p>That’s why TCP feels a bit slower, but it is <strong>very safe</strong>.</p>
<hr />
<h2 id="heading-what-happens-if-a-packet-is-lost">What Happens If a Packet Is Lost?</h2>
<p>If a packet is dropped in between:</p>
<ul>
<li><p>Receiver does not send ACK</p>
</li>
<li><p>Sender waits</p>
</li>
<li><p>After timeout, sender resends the packet</p>
</li>
</ul>
<p>The user never notices anything.<br />TCP works silently in the background.</p>
<hr />
<h2 id="heading-how-a-tcp-connection-is-closed">How a TCP Connection Is Closed</h2>
<p>Even while closing, TCP follows proper rules.</p>
<p>Connection closing steps:</p>
<ol>
<li><p><strong>FIN:</strong> “I’m done sending data”</p>
</li>
<li><p><strong>ACK:</strong> “I understand”</p>
</li>
<li><p>Other side also sends <strong>FIN</strong></p>
</li>
<li><p>Final <strong>ACK</strong> is sent</p>
</li>
</ol>
<p>After this, the connection is safely closed.</p>
]]></content:encoded></item></channel></rss>