← BYTES
Unix IPC·Starter·Ref: 15.1.39

In the most basic sense, why can't an application just immediately reuse a port the instant a connection using it closes, with zero waiting at all?

Have a question about this video? Mention reference 15.1.39 when you contact us.

a.Ports are physically limited hardware resources that need to cool down
b.There is actually no reason at all -- this is a myth with no real basis
c.Reusing it instantly, with no safeguard, risks confusing a late-arriving packet from the OLD connection with the brand-new one using the same port -- TIME_WAIT exists specifically as that safeguard
d.Because the operating system charges a fee for each port reuse
This is the plain-language version of TIME_WAIT's core purpose: without some kind of waiting period, a stray, delayed packet belonging to the just-closed connection could arrive after a brand-new, unrelated connection has already started reusing the exact same local/remote address-and-port combination -- and get misdelivered into it. The advanced sections go into exactly how this is prevented.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES15139#UnixIPC