I am using this excellent answer to find a free port on python: https://stackoverflow.com/a/1365284/1467402
I want this method to pick me any free port, except for a single number. i.e, I want to get any free port except for 8000 since I am saving it for my application.
Is this possible using this method?
This is my code:
def get_free_port():
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("",0))
free_port = s.getsockname()[1]
s.close
return free_port
Thanks