<?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[Working of TCP]]></title><description><![CDATA[Working of TCP]]></description><link>https://working-of-tcp.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 20:14:59 GMT</lastBuildDate><atom:link href="https://working-of-tcp.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[Understand TCP's 3-Way Handshake for reliable, efficient, error-free client-server communication]]></description><link>https://working-of-tcp.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://working-of-tcp.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Hardik Sehgal]]></dc:creator><pubDate>Fri, 23 Jan 2026 03:38:21 GMT</pubDate><content:encoded><![CDATA[<p>Before understanding the whole concept of TCP let’s first understand what were some problems that people faced while Data Transfer. Haha and yes this is way before Air Drop.</p>
<p>TCP means Transmission Control Protocol. In the name only we got protocol which stands for rules and hence this means TCP brings rule on how to transfer Data from Client to Server or Vice-versa</p>
<h2 id="heading-issues-faced-before-tcp-was-even-a-thing">Issues Faced before TCP was even a thing</h2>
<p>Earlier whenever a data is being transferred from server to client or client to server there was no oversight on data, Means</p>
<ol>
<li><p>Is Client and Server both maintained a connection?</p>
</li>
<li><p>Is Data transfer being sent in a correct order like 1, 2, 3✅ and not 1, 3, 2 ❌.</p>
</li>
<li><p>Is there any guarantee/acknowledgement that data is delivered?</p>
</li>
<li><p>Is there a way that we can track each data packets.</p>
</li>
</ol>
<h2 id="heading-how-tcp-fixed-these-issues">How TCP Fixed these Issues?</h2>
<p>Now to solve this problem, TCP was introduced and to this time we are using it while transferring data. TCP as Transmission Control Protocol brings Protocol between client and server. A <strong>protocol</strong> is a set of agreed rules. Agreed rules are predefined protocols and formats that both client and server follow to communicate correctly and reliably. TCP act as an observer of each data packet and ensures data is being transferred without any loss. Below are the steps TCP takes to solve the problem</p>
<ol>
<li><p>TCP establish a three-way handshake between client and server hence ensuring reliable data transfer</p>
</li>
<li><p>TCP Does the chunking of each data and does not send the whole data at once to ensure bandwidth is saved.</p>
</li>
<li><p>It tracks each data packet and sends them in a serialized way.</p>
</li>
<li><p>If few data packets get lost in the time of transfer the TCP ensures re-transmission of the data packet.</p>
</li>
<li><p>Most Important TCP creates a system for sending the data and control the whole flow from start to end</p>
</li>
</ol>
<h2 id="heading-what-is-the-tcp-3-way-handshake">What is the TCP 3-Way Handshake</h2>
<p>Three-way handshake is between Client and Server. This ensures that proper connection is build before sending the Data packets. This is how TCP build the handshake</p>
<ol>
<li><p><strong>Client → SYN</strong><br /> Client sends a request to Server asking permission to connect, or we can say (<strong>SYN</strong> → <strong>Synchronize).</strong> TCP ensure for each type of data for example “Client → SYN” =&gt; I want to start a connection and send Data</p>
</li>
<li><p><strong>Server → SYN-ACK</strong><br /> Server gives a confirmation that it has received and accepts the request of the Client for data transfer (ACK → Acknowledgement) and now server sends a request to the Client (<strong>SYN → Synchronize</strong>) making sure the Client received server’s request</p>
</li>
<li><p><strong>Client → ACK</strong></p>
<p> If Client receives the request of the Server, then it gives the Acknowledgement meaning Client acknowledges server has send a request it accepts the request.</p>
</li>
</ol>
<h2 id="heading-how-data-transfer-works-in-tcp">How data Transfer works in TCP</h2>
<p>TCP does not send the whole data at once because this can cause congestion issue in the bandwidth. Chances of failure increases significantly, and re-transmission becomes very slow since it has to re-transfer the whole data again. Hence TCP uses chunking technique. What it means is TCP Chunks the whole data into smaller parts for example instead of sending “<strong>CHAICODE”</strong> it sends<br />C, H, A, I, C, O, D, E in the network. Receivers reassemble the data and use it accordingly</p>
<p>TCP is also responsible for Sending the data in correct sequence, re-transmission of lost data and also TCP checks each data packet hence discard the corrupt data and re-transmits the correct data</p>
<h2 id="heading-how-a-tcp-connection-is-closed">How a TCP connection is closed</h2>
<p>Just like three-way handshake for establishing a connection there is four-way handshake to close the connection properly. Below are the steps taken by a client and a server to ensure Four-way handshake to close the connection.</p>
<ol>
<li><p><strong>Device sends FIN</strong> =&gt; This could be anyone, either client or server. For now, let’s assume client. Client decides to close the connection because now it does not want any data. So it sends a FIN request to the server.</p>
</li>
<li><p><strong>Receiver sends ACK</strong> =&gt; The receiver (Server in our case) sends an ACK (Acknowledgement) request for the FIN it got, hence confirming the receipt.</p>
</li>
<li><p><strong>Receiver sends FIN =&gt;</strong> The receiving device, now also finished sending data, sends its own FIN packet to the first device.</p>
</li>
<li><p><strong>Initiator Sends Final ACK</strong>\=&gt; The first device acknowledges the second FIN with a final ACK packet, completing the process</p>
</li>
</ol>
]]></content:encoded></item></channel></rss>