Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12041

Re: Order of addresses returned by socket.gethostbyname_ex()

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Order of addresses returned by socket.gethostbyname_ex()
Date 2011-08-22 13:34 -0400
References <356978ef-e9c1-48fd-bb87-849fe8e27a79@p5g2000vbl.googlegroups.com> <roy-44FF9C.07265622082011@news.panix.com> <034ff4bf-e3e4-47ff-9a6c-195412431e73@s20g2000yql.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.323.1314034539.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 8/22/2011 7:39 AM, Tomas Lidén wrote:
> On 22 Aug, 13:26, Roy Smith<r...@panix.com>  wrote:
>> In article
>> <356978ef-e9c1-48fd-bb87-849fe8e27...@p5g2000vbl.googlegroups.com>,
>>   Tomas Lidén<to...@liden-privat.net>  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.
>>
>> Why would you hope that?  Or maybe a better question is, why would you
>> expect that?  In general, all name resolution calls return results in
>> arbitrary order.  In some cases, results are intentionally changed on
>> every call (i.e. round-robin) in an attempt at load sharing.
>>
>> What kind of ordering were you hoping for?
>
> See previous posts.
>
> Basically I was asking about the contract for this method..

The doc "Return a triple (hostname, aliaslist, ipaddrlist) where 
hostname is the primary host name responding to the given ip_address, 
aliaslist is a (possibly empty) list of alternative host names for the 
same address, and ipaddrlist is a list of IPv4/v6 addresses for the same 
interface on the same host (most likely containing only a single address)."

> hoping that it is deterministic.

As far as I can see, that is not in the contract.

> Our testing indicated that the interfaces are returned in a specific
> order, but we want to know if this is really the case (on all
> platforms).

Even if it were so now, a patch could change things.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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