I am writing a code to transfer a large file over the internet. Therefore, I have to open a socket over a specific port (port = 45678) for sending the data. However, it takes a while that the operating system (Ubuntu 14.04) release that specific port (45678) after the program termination.
I want to run my code for multiple times to use that specific port without waiting for the OS to release the port. Is there any way that python forces the OS to release the port?
In addition, all sockets are closed at the end of the file transmission.