I don't think a random port must be used. The issue is whether a port the program chooses is already in use. So I think we should just look for an open port (above 1024) and then use it. I'll consider your algorithm, but it looks like we still need a scheme to choose another port in the probably quite rare chance that someone else grabs that very port in the window that you pointed out.
From: Raghuram Devarakonda <firstname.lastname@example.org>
To: email@example.com <firstname.lastname@example.org>
Cc: email@example.com; firstname.lastname@example.org; email@example.com
Sent: Mon, 13 Aug 2007 10:56 pm
Subject: Re: [Jython-dev] Test SocketServer
On 8/13/07, firstname.lastname@example.org <email@example.com> wrote:
> Does anyone see a problem with replacing this with picking the starting
> port number using a random number between 10001 and 20000 and increasing by
> one? Is there an advantage to using the pid? That would help make this
> test more platform independent. I don't think the Python version runs on
> all Platforms currently.
If a random port must be used, you can use the following function to find one.
s = socket.socket()
port = s.getsockname()
# There is a window here when the port can be taken by some one else.