I'm developing a server using Asio on Linux. Whenever the application gets closed by any means (Ctrl+C, stopping the debugger or getting a crash), it looks like I can't launch the server until after one minute or so. I find this very frustrating for iteration times.
This is the error message I get:
bind: Address already in use
I believe it could be that the port keeps open.
What can I do to to avoid having to wait each time? I would imagine there must be some way to handle terminating the program gracefully by closing the port properly. But I would also like to know a solution that works when I stop the program from the debugger or it crashes.