0

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

4

1 回答 1

1

我想你被一个边缘案例咬了。

归根结底,做一些像休眠这样的事情是高级的东西——将 PC 恢复到它的确切状态并继续,就好像什么都没发生一样。这一切都很好,但有些事情将无法幸存,例如任何期望回复的网络连接,以及任何严重低级的 - 你不能设置我只读我中央处理器。

我建议你联系微软并询问他们是否知道这一点。如果它适用于其他操作系统,他们很可能会对为 7/Vista 修复它感兴趣。只需准备好交出一个二进制文件,以便他们可以无限制地对其进行测试。

于 2010-03-31T00:16:18.893 回答