Understanding TCP Connection Termination: Four-Way Handshake, Half‑Close, Shutdown, and TIME_WAIT
This article explains how TCP connections are gracefully closed using the four‑way handshake, describes half‑close and half‑open states, compares the close and shutdown system calls, details the TIME_WAIT state and its impact, and offers practical techniques to reduce or avoid TIME_WAIT accumulation.