I had a server script running and I closed it prematurely using <kbd>Ctrl</kbd>+<kbd>Z</kbd>. When I tried to run it again it tells me that the port 1001 is already in use. In a live environment there is always the risk that the script could crash or something else may trigger it to end early. How do I automatically unbind this port before connecting to it? I am going to use a port that I know nothing else will ever use, so its safe to unbind it automatically.
Currently my server script is basic.
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
1001
);
$server->run();
I followed the guide found here http://socketo.me/docs/hello-world . Everything has worked as expected, I'mm just stuck with this issue now.
I am running PHP 5.4 on Centos 7.