Dennis Lee Bieber
3/1/2008 6:49:00 PM
On Sat, 1 Mar 2008 04:28:22 -0800 (PST), theneb <onetwofour@gmail.com>
declaimed the following in comp.lang.python:
> On Feb 29, 11:11 pm, Tim Roberts <t...@probo.com> wrote:
> > What's the point? Why can't the actual user of the port create the port,
> > and then notify the other side of the port number?
> The system the app will run on will be creating three instances of the
> external application, the python app has to keep track of which port
> the external app is running on.
>
Still haven't addressed why the instances can't obtain the port on
their own, and send it out on some channel the parent can read
(subprocess/popen stdout/read, say). (or parent opens a port for the
instances to write /their/ ID/port information on)
Any attempt to have parent obtain a port/spawn an external program
with port as argument/release the port/external opens specified port is
going to be a candidate for a race condition.
1) if you don't specify REUSEADDR (or whatever that option really
in named), the port will likely be locked for some period of time after
the parent releases it... I think I've read of timeouts up to two
minutes before a port can be reused.
2) if you DO specify REUSEADDR, the OS is free to give that port to
the next task -- whatever it be, some background job doing a timeserver
synchronization, maybe -- that asks for a free port.
Much better to let the external program obtain whatever port number
it can and tell "you" what it is...
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/