My program bind a port for listening, after it terminates, the port is not available for about a moment and any attempt to open the same port again for listening will fail in that period of time. I need to wait for a while to reopen the port.
I will need to repeatedly bind the port, because I need to retest my server program repeatedly. Is there any linux commands that can release the port prematurely, or any programming code to do the same thing? I code in C++ and uses the gSOAP framework.
Basically I will bind the port using
soap_bind(&newsoap, NULL, 13518, 100);
which I bind the server to listen on port
I have tried the same code in Windows, and the port is immediately available after the program terminate. Do I need to do some extra steps in linux to unbind the port before it terminates?