Opening, owning and closing a TCP connection 00:00:01 CLOSE_WAIT grows after peer disconnects At the end of every interrupted download, another socket stays on Rowan's server. The other end has finished talking. Why is a socket still charged to this process? Two local sockets normally sit in close wait. Under failed transfers the count rises to three hundred ten. Sample the same process twice. A growing group of descriptors that survive completed transfers tells a different story from a single snapshot. TCP is a full-duplex byte stream with independent closure in each direction. A peer FIN says it has finished sending. 00:00:37 Follow both halves of one close After buffered data is consumed the local application sees EOF and must release its end when finished. time wait and close wait have different owners and meanings, even if both appear after a disconnect. The client finishes writing and sends FIN while it can still receive data. The server acknowledges the FIN and enters close wait until its application closes. The server closes its side and sends FIN. The client acknowledges it. In this normal active-close example the client enters time wait and the server closes after the final acknowledgment. 00:01:14 Ask who owns the next transition Would reducing the transport's time wait timer release a descriptor that the application still holds open? The peer's finish signal tells the local endpoint no more data will arrive in that direction. The application can still send before it closes its side. Trace the exceptional return to see whether the owner performs cleanup there too. If time wait dominates and descriptors stay stable, investigate churn or outbound port capacity rather than a missing local close. 00:01:44 Return descriptors after a failed transfer After fixing the cleanup path, four sockets are in close wait under comparable traffic and the count stops accumulating. The header carries ports, sequence and acknowledgment numbers, flags and window information. Interpret a flag with its connection state and acknowledgment progress. Rowan repeats interrupted transfers specifically. A close has two owners and an exception still needs a local ending.