문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top