When I do some programming with sockets in python
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen()
s.settimeout(0.1)
Without closing the socket before exiting the problem, the port will be unavailable for a short amount of time.
I understand that I should properly close the socket before the program exits or closed. However, during development, there are cases where the program will crash/exit before I can take care of the socket.
Why is there a time delay before I can reuse the port again? and how can I avoid such problems?