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

Paul Chitescu paulc at
Mon Apr 14 11:42:26 CDT 2008

On Mon, 14 Apr 2008, Christoph Frick wrote:
> On Mon, Apr 14, 2008 at 04:05:23PM +0200, Kai Blin wrote:
> Hi Kai, et all,
>> +static const char magic_loopback_addr[] = {127, 12, 34, 56};
> in the past wine used to work quite well with the ip-address configured
> using the places in the windows registry (msdn or something similar kept
> an howto for setting the ips in win98 and 2k (and look alikes)). now
> that wine tries to get its ip from the /etc/hosts (or whereever?) i
> noticed some problems with hosting games. as msdn keeps firing errors at
> me i go and ask the list about this.
> i always though windows (at least until xp?) is not capable of listening
> to requests bound to an ip/interface? with the recent changes the games
> listen to lo0 and will never ever accept anything. i had to change my
> /etc/hosts now to make it work again; yet it will fail with more than
> one nic (i have to change /etc/hosts again).
> long story short:
> - does any windows version at all support the idea behind giving an ip
>  to listen for connections like unix/linux/bsd does?
> - and even if: who runs some windows software in wine that needs this
>  features and is not able to fix the problem with the firewall or other
>  restrictions on the unix end?
> if no: what would be needed to change the listening to by
> default? a patch and a test?
> -- 
> cu


All versions of Windows support binding to an IP address - although the 
(preferred) method used for enumerating interfaces and their IP address 
varies with version (not that there is a portable way across *NIXes).

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.


Paul Chitescu

More information about the wine-devel mailing list