Question

Just wondering if anyone else has spotted this:

On some user's machines running our software, occasionally the call to Win32 winsock gethostbyname fails with error code 11004.

For the argument to gethostbyname, I'm passing in the result from gethostname.

Now the docs say 11004 is WSANO_DATA. None of the descriptions seem to be relevant (it occurs if you pass in an IP6 address, but as I say, I'm passing in a hostname).

Even more interesting is that the MSDN suggests that this combination (gethostname followed by gethostbyname) should never fail, not even if there is no IP address (in that case it would just return empty list of IPs). Here is the quote from the gethostname MSDN entry:

...it is guaranteed that the name returned will be successfully parsed by gethostbyname and WSAAsyncGetHostByName.

It only ever happens after resuming from hibernate, in that short period when the network is restarting, and only on Vista/7 (well I've only seen it on Vista and 7).

One theory I had was that it related to IP6. Maybe for a short period the network reports an IP6 address but not the corresponging IP4 address (I'm pretty sure that all the client machines are dual IP stack, but I could be wrong).

I tried to reproduce by turning off my network card (to force no IP addresses) and couldn't reproduce.

Anyone seen this before?

Any ideas?

John

Was it helpful?

Solution

I think you've been bitten by an edge case.

At the end of the day doing something like hibernate is advanced stuff - restoring a PC to its exact state and continuing as if nothing had happened. Thats all well and good, but some things won't have survived, such as any network connections that expected a reply, and any seriously low-level-you-can't-set-me-only-read-me registers in the CPU.

I suggest you contact Microsoft and ask them if they know about this. If it works for other OSes they will most likely be interested in fixing it for 7/Vista. Just be prepared to hand over a binary so they can test it ad-infinitum.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top