gethostbyname(my_name) and IL2-Sturmovik
juan_lang at yahoo.com
Wed Dec 14 11:11:05 CST 2005
Hi David, thanks for continuing to work on this.
> What's wrong with the new version?
The first thing to make it acceptable is to write a regression test to go
along with it. I think the test should check that
gethostbyname(your_host_name) returns something besides 127.0.0.1, _if_
you in fact have a public IP address. Perhaps use SIOCGIFCONF in the test
to check whether you do have a public IP.
+ BOOL getpublicIP(char* target,int size)
The name should be spelled get_public_ip or so, and this should be static.
+ if (skfd < 0)
+ WARN("A socket could not be created");
+ return FALSE;
On any failure you need to SetLastError with an appropriate error.
+ if(ip==127&&ip==0&&ip==0&&ip==0)continue; /*Exclude
I think this is specific to little-endian machines, this should succeed on
big-endian machines too. (Not all uses of Wine are to run x86
Some spaces somewhere would be nice :)
+ char myname;
In WS_gethostbyname you pay a penalty of doing a gethostname call every
time. I think this could be optimized. For instance, you could only
check it if the returned address is 127.0.0.1. Also, I'm not sure about
declaring a buffer of 1000 bytes on the stack. It's also unnecessary:
according to rfc1035, each name label is at most 255 chars. I assume, at
any rate, that gethostname will not return a dotted name, but a single
To get this off the stack altogether, you could have a static buffer
that's set every time WS_gethostname is called. WS_gethostbyname could
use this value instead of calling gethostname(2) itself. I'm not sure
whether this optimization is worth it. If you use a static buffer, it
needs to be protected by a critical section.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the wine-devel