<?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 Working: 3-Way Handshake]]></title><description><![CDATA[TCP Working: 3-Way Handshake]]></description><link>https://tcphandshake1.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 05:53:53 GMT</lastBuildDate><atom:link href="https://tcphandshake1.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[When computers communicate over a network, they don’t magically understand each other.If data is sent without rules, packets can arrive late, out of order, or not arrive at all.This is exactly the problem TCP was designed to solve.

What is TCP and W...]]></description><link>https://tcphandshake1.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://tcphandshake1.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><category><![CDATA[tcp 3-way-handshake-and-reliable]]></category><dc:creator><![CDATA[Rahul Rajak]]></dc:creator><pubDate>Fri, 30 Jan 2026 10:53:31 GMT</pubDate><content:encoded><![CDATA[<p>When computers communicate over a network, they don’t magically understand each other.<br />If data is sent without rules, packets can arrive late, out of order, or not arrive at all.<br />This is exactly the problem <strong>TCP</strong> was designed to solve.</p>
<hr />
<h2 id="heading-what-is-tcp-and-why-it-is-needed">What is TCP and Why It Is Needed</h2>
<p><strong>TCP (Transmission Control Protocol)</strong> is a protocol that establishes a connection before sending data.</p>
<p>It makes sure that:</p>
<ul>
<li><p>Data is delivered correctly</p>
</li>
<li><p>Data arrives in the right order</p>
</li>
<li><p>Lost data is detected and resent</p>
</li>
</ul>
<p>This is why TCP is used for things like:</p>
<ul>
<li><p>Web browsing</p>
</li>
<li><p>Emails</p>
</li>
<li><p>File transfers</p>
</li>
</ul>
<p>In these cases, <strong>accuracy matters more than speed</strong>.<br />A broken web page or a corrupted email is unacceptable.</p>
<hr />
<h2 id="heading-what-happens-if-data-is-sent-without-rules">What Happens If Data Is Sent Without Rules</h2>
<p>Imagine two people talking without waiting for responses.</p>
<p>One speaks fast, the other misses words, sentences overlap, and parts of the message are lost.<br />That’s what network communication would look like <strong>without TCP</strong>.</p>
<p>UDP works like this — fast, but unreliable.<br />TCP exists to bring <strong>discipline and structure</strong> to communication.</p>
<hr />
<h2 id="heading-tcp-vs-udp">TCP vs UDP</h2>
<p>UDP sends data without checking anything.<br />It doesn’t establish a connection and doesn’t care if data is lost.</p>
<p>That’s fine for:</p>
<ul>
<li><p>Video calls</p>
</li>
<li><p>Live matches</p>
</li>
<li><p>Online gaming</p>
</li>
</ul>
<p>But TCP is used when <strong>every bit of data matters</strong>.</p>
<hr />
<h2 id="heading-how-tcp-establishes-a-connection-the-3-way-handshake">How TCP Establishes a Connection: The 3-Way Handshake</h2>
<p>Before sending actual data, TCP first checks:<br />“Are you ready to talk?”<br />“Yes, I am.”<br />“Okay, let’s start.”</p>
<p>This process is called the <strong>3-Way Handshake</strong>.</p>
<p>Think of it like a phone call.</p>
<hr />
<h2 id="heading-step-by-step-syn-syn-ack-ack">Step-by-Step: SYN, SYN-ACK, ACK</h2>
<h3 id="heading-step-1-syn-client-server">Step 1: SYN (Client → Server)</h3>
<p>The client sends a message saying:</p>
<blockquote>
<p>“I want to talk.”</p>
</blockquote>
<p>This message is called <strong>SYN</strong> (synchronize).</p>
<h3 id="heading-step-2-syn-ack-server-client">Step 2: SYN + ACK (Server → Client)</h3>
<p>The server replies:</p>
<blockquote>
<p>“I received your request, and I’m ready.”</p>
</blockquote>
<p>This response is <strong>SYN + ACK</strong>.</p>
<h3 id="heading-step-3-ack-client-server">Step 3: ACK (Client → Server)</h3>
<p>The client responds:</p>
<blockquote>
<p>“I received your response.”</p>
</blockquote>
<p>This final message is <strong>ACK</strong>.</p>
<p>Now both sides agree:</p>
<ul>
<li><p>The connection is established</p>
</li>
<li><p>Data transfer can begin</p>
</li>
</ul>
<p>Only <strong>after this</strong> does real data start flowing.</p>
<hr />
<h2 id="heading-how-data-transfer-works-in-tcp">How Data Transfer Works in TCP</h2>
<p>Once the connection is open, TCP sends data in small chunks called <strong>segments</strong>.</p>
<p>In this way the data is transfered:</p>
<ul>
<li><p>Data arrives in order</p>
</li>
<li><p>Missing data is detected</p>
</li>
<li><p>Duplicate data is ignored</p>
</li>
</ul>
<hr />
<h2 id="heading-how-tcp-ensures-reliability">How TCP Ensures Reliability</h2>
<p>TCP constantly checks:</p>
<ul>
<li><p>Was the data received?</p>
</li>
<li><p>Was it received in the correct order?</p>
</li>
<li><p>Did anything get lost?</p>
</li>
</ul>
<p>If something is missing:</p>
<ul>
<li><p>TCP <strong>resends the data</strong></p>
</li>
<li><p>Slows down if the network is congested</p>
</li>
<li><p>Adjusts speed automatically</p>
</li>
</ul>
<p>This is why TCP is reliable but slower than UDP.</p>
<hr />
<h2 id="heading-how-a-tcp-connection-is-closed">How a TCP Connection Is Closed</h2>
<p>Ending a TCP connection is more careful than starting one.<br />TCP does not suddenly cut the connection, because there might be transporting data.</p>
<p>TCP uses a <strong>4-way handshake</strong> to close a connection safely.</p>
<h3 id="heading-step-1-fin-client-server">Step 1: FIN (Client → Server)</h3>
<p>When one side finishes sending data, it sends a <strong>FIN</strong> message.</p>
<p>This means:</p>
<blockquote>
<p>“I’m done sending data to you.”</p>
</blockquote>
<p>At this point:</p>
<ul>
<li><p>The client will not send more data</p>
</li>
<li><p>But it can still <strong>receive</strong> data from the server</p>
</li>
</ul>
<h3 id="heading-step-2-ack-server-client">Step 2: ACK (Server → Client)</h3>
<p>The server replies with an <strong>ACK</strong>.</p>
<p>This means:</p>
<blockquote>
<p>“I received your FIN. I know you are done sending.”</p>
</blockquote>
<p>Now:</p>
<ul>
<li><p>The client waits</p>
</li>
<li><p>The server may still have data left to send</p>
</li>
</ul>
<h3 id="heading-step-3-fin-server-client">Step 3: FIN (Server → Client)</h3>
<p>When the server also finishes sending its remaining data, it sends its own <strong>FIN</strong>.</p>
<p>This means:</p>
<blockquote>
<p>“I’m also done sending data.”</p>
</blockquote>
<p>Now both sides have said they are finished sending.</p>
<h3 id="heading-step-4-ack-client-server">Step 4: ACK (Client → Server)</h3>
<p>Finally, the client sends an <strong>ACK</strong> back to the server.</p>
<p>This means:</p>
<blockquote>
<p>“I received your FIN. We are done.”</p>
</blockquote>
<p>After this:</p>
<ul>
<li><p>The connection is fully closed</p>
</li>
<li><p>All resources are released</p>
</li>
<li><p>No data is lost</p>
</li>
</ul>
<hr />
<h2 id="heading-why-this-matters-for-developers">Why This Matters for Developers</h2>
<p>Whenever you Open a website:</p>
<p>TCP works as:</p>
<ul>
<li><p>Establishing connections</p>
</li>
<li><p>Managing data flow</p>
</li>
<li><p>Handling packet loss</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>