Launcher returns EADDRINUSE for binding a second time

Possible duplicates:
Releasing the associated ports at the end of the process, the
difference between the "used address" with bind () on Windows and Linux is errno = 98

I have a simple server application that I write for Linux, and it works decently on the first start, but for some reason it does not free the port on exit. It seems I need to wait some kind of timeout before I can restart the application to get the port. Otherwise, I get an EADDRINUSE error in the bind call.

I feel that I must be doing something stupid, but for a while I hit my head about this problem and did not understand it, so if someone could point me in the right direction, that would be great. I tried to close the connected and accepted sockets many times, and at different points, but no luck.

+3
source share

Source: https://habr.com/ru/post/1793338/


All Articles