When you start a program to listen on a TCP socket then kill the program, sometimes (but not always) you get an error like "address already in use" when you try to listen on the socket again for the next few mins. The proc is killed with ctrl-c. I use linux.
I think this has something to do with a TCP connection being stuck in the CLOSE_WAIT state, but am not 100% sure. Why exactly do I get the "address already in use" error?
Also, why does this only sometimes happen?