Order of addresses returned by socket.gethostbyname_ex()
Roy Smith
roy at panix.com
Mon Aug 22 08:14:10 EDT 2011
In article
<034ff4bf-e3e4-47ff-9a6c-195412431e73 at s20g2000yql.googlegroups.com>,
Tomas Lidén <tomas.liden.privat at gmail.com> wrote:
> Basically I was asking about the contract for this method.. hoping
> that it is deterministic.
The contract for socket.gethostbyname_ex() is described at
http://docs.python.org/library/socket.html#socket.gethostbyname_ex. It
says:
"Translate a host name to IPv4 address format, extended interface.
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 addresses for the same interface on the
same host (often but not always a single address). gethostbyname_ex()
does not support IPv6 name resolution, and getaddrinfo() should be used
instead for IPv4/v6 dual stack support."
That's it. It says nothing about ordering, so nothing about ordering
should be inferred.
> 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).
No, it is not.
More information about the Python-list
mailing list