gethostbyname(my_name) and IL2-Sturmovik CONTINUED

Kai Blin kai.blin at gmail.com
Fri Apr 20 10:46:07 CDT 2007


On Friday 20 April 2007 15:37, Dan Kegel wrote:
> Briareos wrote:
> > The Problem: gethostbyname(own_name) always returns 127.0.0.1. ...
> > To me it's logical that you get 127.0.0.1 when pinging your local
> > hostname, but if windows does give the IP of your NIC then wine should do
> > as well - as we want to reach compatibility.
> >
> >If, on the other hand, you say it's simply bad programming done by the
> >app-developer if he tries to fetch the IP of the NIC that way, I'd say
> > let's still comply to it, because its more likely than having a
> > programmer expecting to get 127.0.0.1 when asking for "localhostname".
>
> My understanding is that hostnames are not really hostnames, but
> interface names.
> On Unix, 127.0.0.1 is never normally returned unless you ask for
> literally "localhost".  I suspect Windows behaves like Unix here.
> So this probably is a valid bug in wine.

Looking at a simple test that does (pseudocode)

gethostname(name, len);
hostent = gethostbyname(name);

Windows will return 127.0.0.1 if there's no valid IP defined and there's no IP 
that used to be valid either.

Anyhow, it seems that if there is an IP address that's not loopback, that is 
returned instead. I'm afraid that won't be easy to fix.. :(

> (I suspect that the app developer is misguided, because binding
> to just one interface doesn't work well if you have multiple
> interfaces, but that's neither here nor there.)

Well, actually the developer of the app in #7929 is misguided because he's 
using gethostbyname() with winsock 2.2, which MSDN claims is deprecated. Oh 
well.

Cheers,
Kai

-- 
Kai Blin, <kai Dot blin At gmail Dot com>
WorldForge developer    http://www.worldforge.org/
Wine developer          http://wiki.winehq.org/KaiBlin/
--
Will code for cotton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070420/40b0efb9/attachment.pgp


More information about the wine-devel mailing list