gethostbyname on local host returns 127.0.0.1 for address
reif at earthlink.net
Thu Aug 19 06:26:36 CDT 2004
Juan Lang wrote:
>>On windows gethostbyname for the local host returns
>>the addresses of the available network interfaces.
>>On wine and unix, it only returns the localhost
>>Any ideas on how to get the windows behavior?
>I assume you're referring to gethostname (as in your
>sample code), not gethostbyname (as in your email).
>Well, I guess you'd have to modify winsock/socket.c's
>WS_gethostname function, maybe to call GetAdaptersInfo
>or some such. That'll get you the addresses, anyway.
>If you want a name other than localhost you may want
>to call GetNetworkParams too.
It's gethostbyname that has the problem. gethostname is
just used to find the name of the machine that the program
is running on and is what is passed to gethostbyname.
gethostbyname should return a host structure which contains
an array of addresses associated with the host. On windows,
the addresses are the addresses of the network interfaces.
On wine and unix, the address returned is 127.0.0.1 which
is localhost, not the actual interface address.
More information about the wine-devel