Possible Duplicates:
Releasing bound ports on process exit
difference between “address in use” with bind() in Windows and on Linux - errno=98
I have a simple server application I'm writing for Linux and it works decently the first time I run it, but for some reason it's not releasing the port on exit. It seems like I have to wait for some kind of timeout before I can rerun the application to get the port. Otherwise I get an EADDRINUSE error on the bind call.
I feel like I must be doing something stupid, but I have been banging my head against the problem for a while and haven't figured it out, so if someone can point me in the right direction that'd be great. I've tried closing the bound and accepted sockets many times, and at different points, but no luck.