check for unused ports and then grab one

Alex Martelli aleaxit at yahoo.com
Wed Sep 15 12:47:36 EDT 2004


Peter Hansen <peter at engcorp.com> wrote:
   ...
> > prefer not to hard code it. Each server will have a client component
> > that grabs the current IP (dhcp) and port number the server is using and
> > then sends it to a separate machine (sys-admin workstation) that is
   ...
> in the same situation I'd make the choice to assign a port to
> the service permanently (and hardcode or whatever), but I have
> to admit I don't have all the details so maybe I'd take your
> approach, too. :-)

One key detail we have is that the current IP cannot be known in
advance, thanks to DHCP -- it has to be communicated dynamically to a
sys-admin workstation.  Given that key detail, I see no problem having
to communicate the port number as well as the IP address, thus no
advantage in hardwiring the port number -- as long as no firewalls and
similar hacks are in the way, of course.

One alternate approach might be to support zeroconf/rendezvous/
opentalk/or however it's called today.  Basically, it's a clever hack on
top of DNS, recently blessed by the IETF (not sure about the RFC number,
but no doubt they did assign one to it when they blessed it), that makes
it a cakewalk for servers and clients for any given protocol to find
each other, just as long as they know the name of the protocol.  Well
supported for Python as well as any other language you may care about (a
Ruby interface was put together by two people hacking on their laptops
in the half-day of time zeroconf's inventor and chief prophet, Stuart
Cheshire, was tutorialing about it at OSCON...), native on Macs, a
simple add-on for Windows and Linux, lightweight, potentially tiny (a
suitably slimmed-down minimal implementation was fitted into ROM on the
8-bit embedded processor-cum-ROM of some standalone net-connected webcam
in just a few Kb...!)... a true delight, all it needs is for more apps
to support it (and I like it a lot, which is why I miss no occasion to
offer a plug fot it;-).


Alex



More information about the Python-list mailing list