ws2_32: Work around the host name resolving to 127.x.x.x when using that for binding.

Kai Blin kai.blin at
Mon Apr 14 16:04:52 CDT 2008

On Monday 14 April 2008 18:42:26 Paul Chitescu wrote:

> Binding to a specific address is the only easy way of detecting which
> interface an UDP packet was received on since recvfrom() only gives source
> address, not destination. Listening on would make impossible to
> tell which interface a packet was received on. Furthermore, a program that
> explicitely tries to bind to each interface would fail all but the first
> bind and possibly bail out. Probably many games that use UDP would break.

I'm currently trying to fix apps that fail doing the following (which seems to 
be a popular way among game developers), in pseudo-code. 

hostname = gethostname();
hostent = gethostbyname(hostname);
sockaddr->sin_addr = hostent->addr;
sock = socket();
bind(sock, sockaddr);

Which, as Christoph noted, cause windows apps to bind to loopback addresses, 
breaking the networking. This only started to happen recently as recently 
Linux distros started mapping the machine's hostname to a loopback address. I 
don't think Wine ever used the registry for anything like that.


Kai Blin
WorldForge developer
Wine developer
Samba team member
Will code for cotton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : 

More information about the wine-devel mailing list