kb/data/developer.mozilla.org/en-US/docs/Glossary/TCP_handshake-0.md

11 KiB

title chunk source category tags date_saved instance
TCP handshake - Glossary | MDN 1/3 https://developer.mozilla.org/en-US/docs/Glossary/TCP_handshake reference web, html, css, javascript, documentation 2026-05-05T05:46:40.383270+00:00 kb-cron

MDN HTML HTML: Markup language

HTML reference

HTML guides

Markup languages

CSS CSS: Styling language

CSS reference

CSS guides

Layout cookbook

JavaScriptJS JavaScript: Scripting language

JS reference

JS guides

Web APIs Web APIs: Programming interfaces

Web API reference

Web API guides

All All web technology

Technologies

Topics

Learn Learn web development

Frontend developer course

Learn HTML

Learn CSS

Learn JavaScript

Tools Discover our tools

About Get to know MDN better

Blog

  1. Glossary
  2. TCP handshake

TCP handshake

TCP (Transmission Control Protocol) uses a three-way handshake (aka TCP-handshake, three message handshake, and/or SYN-SYN-ACK) to set up a TCP/IP connection over an IP based network. Similarly, a four-way handshake is used to terminate the connection. The three messages transmitted by TCP to negotiate and start a TCP session are nicknamed SYN, SYN-ACK , and ACK for SYN chronize, SYN chronize-ACK nowledgement, and ACK nowledge respectively. The three message mechanism is designed so that two computers that want to pass information back and forth to each other can negotiate the parameters of the connection before transmitting data such as HTTP browser requests.

  1. The initiator, generally the browser, sends a TCP SYNchronize packet to the other host, generally the server.
  2. The server receives the SYN and sends back a SYNchronize-ACKnowledgement.
  3. The initiator receives the server's SYN-ACK and sends an ACKnowledge. The server receives ACK and the TCP socket connection is established.

This handshake step happens after a DNS lookup and before the TLS handshake, when creating a secure connection. The connection can be terminated independently by each side of the connection via a four-way handshake, where a pair of FIN (finish) and ACK messages are sent and received independently by each side.

  1. The initiator sends a FIN packet to the other host.
  2. The other host sends an ACK packet back to the initiator.
  3. Now, the connection is half-closed, and the other host can still send data. (For example, the server can finish off sending data to the client when the client has closed its connection to the server.)
  4. The other host sends a FIN packet to the initiator.
  5. The initiator sends an ACK packet back to the other host.

In this article

See also