When running a code that is supposed to read from a TCP/IP port I often get the following message (depending exactly what language have been used):
socket_bind(): unable to bind address
I know that this happens when some other process listens to this port / is binded to this port (I do not know the exact phrase to describe), and therefore my code cannot listen to that port. However, it is my code which I just stopped (by CTRL-C) that is blocking this port! There seem to be some timeout involved, and after waiting some time (about 30 seconds) I can start my code to listen on this specific port without problems.
I would like to know:
- Why is the port still blocked although I have stopped the code?
- How can I force the system to release this port so I can restart my code and start listening to this port?