A、采用gethostbyaddr阻塞时间不管成功与否为4秒左右。
例子:


1 LONG lPort=3024;
2
3 struct sockaddr_in ServerHostAddr;//服务主机地址
4
5 ServerHostAddr.sin_family=AF_INET;
6
7 ServerHostAddr.sin_port=::htons(u_short(lPort));
8
9 ServerHostAddr.sin_addr.s_addr=::inet_addr("192.168.1.3");
10
11 HOSTENT* pResult=gethostbyaddr((const char *) &
12
13 (ServerHostAddr.sin_addr.s_addr),4,AF_INET);
14
15 if(NULL==pResult)
16
17 {
18
19 int nErrorCode=WSAGetLastError();
20
21 TRACE("gethostbyaddr errorcode=%d",nErrorCode);
22
23 }
24
25 else
26
27 {
28
29 TRACE("gethostbyaddr %s"n",pResult->h_name);;
30
31 }
B、采用PING方式时间约2秒左右