Alex said:
I'm launching another server (non python) from python and I have to
designate which port that server should bind to.
If I understand correctly, then you have only two
clear options:
1. Launch the server on whatever port, and make sure you
can identify its failure when that port is in use.
Presumably then you can just step your way through the
available ports until one of them "takes".
2. Check the port ahead of time, using the pattern of
"bind to port, catch exception if in use, release port if
not in use", then basically do #1, noting that if you
can't catch the server failing you will still have the
slight possibility that something else could grab the
port in the meantime. I suspect that's unlikely to happen
in your case, so you can likely ignore that.
-Peter