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


Groups > comp.lang.python > #12006

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'received:edu.au': 0.07; 'seemed': 0.07; 'etc).': 0.09; 'order?': 0.09; 'subject:()': 0.09; 'subject:addresses': 0.09; 'interfaces': 0.12; 'hopefully': 0.15; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'lan': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'vmware': 0.16; 'wifi,': 0.16; 'cc:addr:python-list': 0.16; 'mon,': 0.16; 'written': 0.16; 'wrote:': 0.16; "wouldn't": 0.17; 'cheers,': 0.18; 'to:2**1': 0.20; 'cc:no real name:2**0': 0.20; 'connections': 0.21; 'holds': 0.21; 'cc:2**0': 0.22; 'header:In- Reply-To:1': 0.22; '(or': 0.23; 'aug': 0.24; 'windows': 0.26; 'host': 0.27; 'order.': 0.29; 'cc:addr:python.org': 0.30; 'lines': 0.30; 'influenced': 0.30; 'yields': 0.30; 'specified': 0.31; 'go.': 0.32; 'usually': 0.32; 'header:User-Agent:1': 0.34; 'to:no real name:2**1': 0.35; 'running': 0.35; 'connection': 0.36; 'received:au': 0.36; 'interface.': 0.37; 'platforms': 0.37; 'using': 0.37; 'several': 0.37; 'but': 0.37; 'something': 0.37; 'especially': 0.37; 'configured': 0.38; 'steven': 0.38; 'addresses': 0.38; 'subject:: ': 0.39; 'returned': 0.39; 'getting': 0.39; "there's": 0.39; 'case': 0.39; 'your': 0.61; 'hope': 0.61; 'six': 0.61; 'order': 0.62; 'our': 0.63; 'information,': 0.65; 'received:202': 0.66; 'cameron': 0.67; 'us.': 0.70; 'imagine': 0.71; 'become': 0.71; 'order,': 0.73; 'subject:Order': 0.77; '04:37': 0.84; 'adapter': 0.84; 'yourself?': 0.84; 'man,': 0.91; 'subject:skip:s 20': 0.91; 'surprise': 0.97
Date Mon, 22 Aug 2011 20:06:46 +1000
From Cameron Simpson <cs@zip.com.au>
To Tomas@cskk.homeip.net, Lid�n <tomas.liden.privat@gmail.com>@cskk.homeip.net
Subject Re: Order of addresses returned by socket.gethostbyname_ex()
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Disposition inline
Content-Transfer-Encoding 8bit
In-Reply-To <c4163eeb-c306-49d1-9337-0eb9f47df52f@s12g2000yqm.googlegroups.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <c4163eeb-c306-49d1-9337-0eb9f47df52f@s12g2000yqm.googlegroups.com>
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.306.1314007617.27778.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1314007617 news.xs4all.nl 23881 [2001:888:2000:d::a6]:41246
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12006

Show key headers only | View raw


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 | 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