Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12006
| Date | 2011-08-22 20:06 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: Order of addresses returned by socket.gethostbyname_ex() |
| References | <c4163eeb-c306-49d1-9337-0eb9f47df52f@s12g2000yqm.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.306.1314007617.27778.python-list@python.org> (permalink) |
On 22Aug2011 02:06, Tomas Lid�n <tomas.liden.privat@gmail.com> wrote: | On 22 Aug, 10:15, Steven D'Aprano <steve | +comp.lang.pyt...@pearwood.info> wrote: | > On Mon, 22 Aug 2011 04:37 pm Tomas Lidén wrote: | > > In what order are the addresses returned by socket.gethostbyname_ex()? | > | > > We know that gethostbyname() is indeterministic but hope that | > > gethostbyname_ex() has a specified order. | > | > Did you want a particular order, or just any deterministic order? | > | > Have you considered sorting the addresses yourself? | | In this particular case we have a host with several connections (LAN, | WIFI, VmWare adapters etc). When using gethostbyname() we got a VmWare | adapter but we wanted to get the LAN (or the "best" connection to our | server). With gethostbyname_ex() the ordering seemed to become LAN, | Wifi, etc and that's good for us. But we don't know if this holds on | other platforms (we're running on Windows 7). | | A cross-platform deterministic order would be excellent for us. It would not surprise me if the order was related to the order a scan of the system interfaces yields information, and I would imagine that may be influenced by the order in which the interfaces were initialised. So getting the LAN first may merely be fortuitous. I wouldn't rely on it, especially if interfaces come and go. What if you queried your routing table instead? Usually there's just one default route, and hopefully it would be configured to use the "best" interface. Cheers, -- Cameron Simpson <cs@zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/ If you give me six lines written by the most honest man, I will find something in them to hang him. - Cardinal Richilieu
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Order of addresses returned by socket.gethostbyname_ex() Tomas Lidén <tomas@liden-privat.net> - 2011-08-21 23:37 -0700
Re: Order of addresses returned by socket.gethostbyname_ex() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-22 18:15 +1000
Re: Order of addresses returned by socket.gethostbyname_ex() Tomas Lidén <tomas.liden.privat@gmail.com> - 2011-08-22 02:06 -0700
Re: Order of addresses returned by socket.gethostbyname_ex() Cameron Simpson <cs@zip.com.au> - 2011-08-22 20:06 +1000
Re: Order of addresses returned by socket.gethostbyname_ex() Tomas Lidén <tomas.liden.privat@gmail.com> - 2011-08-22 04:29 -0700
Re: Order of addresses returned by socket.gethostbyname_ex() Cameron Simpson <cs@zip.com.au> - 2011-08-23 08:46 +1000
Re: Order of addresses returned by socket.gethostbyname_ex() Chris Angelico <rosuav@gmail.com> - 2011-08-22 11:36 +0100
Re: Order of addresses returned by socket.gethostbyname_ex() Tomas Lidén <tomas.liden.privat@gmail.com> - 2011-08-22 04:32 -0700
Re: Order of addresses returned by socket.gethostbyname_ex() Roy Smith <roy@panix.com> - 2011-08-22 07:37 -0400
Re: Order of addresses returned by socket.gethostbyname_ex() Paul Kölle <paul@subsignal.org> - 2011-08-22 14:18 +0200
Re: Order of addresses returned by socket.gethostbyname_ex() Tomas Lidén <tomas.liden.privat@gmail.com> - 2011-08-22 05:33 -0700
Re: Order of addresses returned by socket.gethostbyname_ex() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-23 02:09 +1000
Re: Order of addresses returned by socket.gethostbyname_ex() Roy Smith <roy@panix.com> - 2011-08-22 07:26 -0400
Re: Order of addresses returned by socket.gethostbyname_ex() Tomas Lidén <tomas.liden.privat@gmail.com> - 2011-08-22 04:39 -0700
Re: Order of addresses returned by socket.gethostbyname_ex() Roy Smith <roy@panix.com> - 2011-08-22 08:14 -0400
Re: Order of addresses returned by socket.gethostbyname_ex() Terry Reedy <tjreedy@udel.edu> - 2011-08-22 13:34 -0400
Re: Order of addresses returned by socket.gethostbyname_ex() Nobody <nobody@nowhere.com> - 2011-08-22 20:12 +0100
csiph-web