gethostbyname(my_name) and IL2-Sturmovik

David Nolden at
Mon Dec 12 09:44:23 CST 2005

Hi everybody. Currently, my favorite Game is "IL2-Sturmovik Forgotten 
Battles", especially it's online-mode. The Game itself is running nearly 
flawless and at good performance, but I encountered a network-problem which 
didn't allow the game to connect to any remote server, so I've analyzed and 
solved the problem.

This is what the game does:
1. Create a Datagram-socket
2. Call gethostbyname(own_name) to find out the current IP-Adress
3. Bind the socket to that IP-Adress
4. Try connecting to the remote game using exactly that socket

The Problem: gethostbyname(own_name) always returns I've searched a 
bit on the internet, and this seems always to be the case, not just on my 

The socket is then bound to the ip-adress, and to it's corresponding 
loopback-interface, so it's unusable. Any connection-request times out.

I don't really know much about Networking itself, I just know how to use 
IP-Networking, but I think it's pretty boring(especially the way it all is 
implemented) so I don't even know what IPV6 is, and I don't know if my patch 
is compatible with it(although I think so). Also I don't know if returning is in fact not a bug but desired, and the game is doing something 
wrong here.

But if it is desired that gethostbyname(own_name) preferrably returns the 
public IP-Adress, then this code should solve the problem, although maybe a 
bit more checking should be done which IP-Adress should be chosen as the 
public one for cases with multiple non-loopback-interfaces.

I submit this patch to the wine-devel-list so people who know more about all 
the network-handling can discuss about it, and decide whether it should be 
put to cvs, or whether there is a better Solution for this problem.

The Code enumerates all available Interfaces through the kernel, and decides 
which one should be used in a very naive way.

David Nolden (btw. my subscription to the list doesn't seem to be complete 
yet, I'm sending this anyway)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gethostbyname_nolden.diff
Type: text/x-diff
Size: 4028 bytes
Desc: not available
Url :

More information about the wine-devel mailing list