Order of addresses returned by socket.gethostbyname_ex()

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Aug 22 12:09:50 EDT 2011


Tomas Lidén wrote:


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

Define "best" connection.

If I tell you that my server has the following 6 connections:

Wifi1, LAN4, LAN1, LAN2, Wifi2, LAN5

which one is "best"?

Once you have an algorithm for deciding which connection is "best" for
everybody, then you can check whether gethostbyname_ex uses that algorithm,
or some other one.



-- 
Steven




More information about the Python-list mailing list