Closed azjezz closed 4 years ago
It's not necessarily that it's actually in-use, or that it's still listening: the usual cause is the server has stopped, but the socket remains in TIME_WAIT state for several minutes. This is standard, defined behavior of TCP. Most operating systems let you ignore TIME_WAIT with SO_REUSEADDR, but this does potentially cause problems if there were any packets sent to the old server but not yet received.
It should be added to the HSL
no way to set SO_REUSEADDR
Note: this is not just about reusing already in use addresses, but also stopping servers to free up the port.
Ah, you're trying to reuse the same port in the same process, just not at the same time? If so, shoudl have a separate issue for each
Ah, you're trying to reuse the same port in the same process, just not at the same time
yes, or in a different process :)
i just want to make sure i can free up the port when the process is killed via pcntl_signal
:)
when the process is killed via pcntl_signal
AIUI this is entirely the SO_REUSEADDR/TIME_WAIT case
We definitely should have the ability to stop the server, but it's not needed/doesn't help for "I want the port when the process exits" case
example :