Please help,
At first, I created a socket and bound it to address without SO_REUSEADDR.
Then, my program crashed (not properly closing socket)
Next, I run it again and “Address already in use” is returned from bind()
I tried to modify source code to use SO_REUSEADDR but it is no-use.
Now, I couldn’t run bind again (the server can’t be rebooted)
You just need to wait until the session times out, then it will be deleted completely.
When a session shuts down in a “dirty” manner, you can’t reuse that address again (assuming you’re not using SO_REUSEADDR) for twice the maximum segment lifetime – typically this is about four minutes for regular network hardware though it actually depends on the properties of the medium (satellites may have a larger MSL for example).
This is to ensure that any packets still in transition don’t arrive and screw up your sequencing on the new session.