AlgoViz

Opening, owning and closing a TCP connection

medium 7 min

TCP is a full-duplex byte stream with independent closure in each direction.

Where it shows up

The same pattern appears across everyday software.

  • CLOSE_WAIT grows after peer disconnects

    A service stops opening connections after sustained traffic. Group socket states by owning process and sample twice. Growing CLOSE_WAIT alongside a rising descriptor count suggests an application cleanup path that never closes after peer shutdown. Before changing kernel timers, identify whether the application or the transport owns the next transition.

  • Verifying the intervention

    Close on every completion path and repeat failed transfers while monitoring counts. If TIME_WAIT dominates and descriptors stay stable, investigate churn or outbound port capacity rather than a missing local close.