487 (timeout < 1000) ? 1000 : timeout); // DWORD Timeout 488 } 489 490 if (dwRetVal == 0) { // if the call failed 491 TCHAR *buf; 492 DWORD err = WSAGetLastError(); 493 switch (err) { 494 case ERROR_NO_NETWORK: 495 case ERROR_NETWORK_UNREACHABLE: 496 case ERROR_HOST_UNREACHABLE: 497 case ERROR_PROTOCOL_UNREACHABLE: 498 case ERROR_PORT_UNREACHABLE: 499 case ERROR_REQUEST_ABORTED: 500 case ERROR_INCORRECT_ADDRESS: 501 case ERROR_HOST_DOWN: 502 case WSAEHOSTUNREACH: /* Host Unreachable */ 503 case WSAENETUNREACH: /* Network Unreachable */ 504 case WSAENETDOWN: /* Network is down */ 505 case WSAEPFNOSUPPORT: /* Protocol Family unsupported */ 506 case IP_REQ_TIMED_OUT: 507 break; 508 default: 509 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 510 NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 511 (LPTSTR)&buf, 0, NULL); 512 NET_ThrowNew(env, err, buf); 513 LocalFree(buf); 514 break; 515 } 516 } else { 517 PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer; 518 519 // This is to take into account the undocumented minimum 520 // timeout mentioned in the IcmpSendEcho call above. 521 // We perform an extra check to make sure that our 522 // roundtrip time was less than our desired timeout 523 // for cases where that timeout is < 1000ms. 524 if (pEchoReply->Status == IP_SUCCESS 525 && (int)pEchoReply->RoundTripTime <= timeout) 526 { | 487 (timeout < 1000) ? 1000 : timeout); // DWORD Timeout 488 } 489 490 if (dwRetVal == 0) { // if the call failed 491 TCHAR *buf; 492 DWORD err = WSAGetLastError(); 493 switch (err) { 494 case ERROR_NO_NETWORK: 495 case ERROR_NETWORK_UNREACHABLE: 496 case ERROR_HOST_UNREACHABLE: 497 case ERROR_PROTOCOL_UNREACHABLE: 498 case ERROR_PORT_UNREACHABLE: 499 case ERROR_REQUEST_ABORTED: 500 case ERROR_INCORRECT_ADDRESS: 501 case ERROR_HOST_DOWN: 502 case WSAEHOSTUNREACH: /* Host Unreachable */ 503 case WSAENETUNREACH: /* Network Unreachable */ 504 case WSAENETDOWN: /* Network is down */ 505 case WSAEPFNOSUPPORT: /* Protocol Family unsupported */ 506 case IP_REQ_TIMED_OUT: 507 case ERROR_INVALID_COMPUTERNAME: 508 case ERROR_INVALID_NETNAME: 509 break; 510 default: 511 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 512 NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 513 (LPTSTR)&buf, 0, NULL); 514 NET_ThrowNew(env, err, buf); 515 LocalFree(buf); 516 break; 517 } 518 } else { 519 PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer; 520 521 // This is to take into account the undocumented minimum 522 // timeout mentioned in the IcmpSendEcho call above. 523 // We perform an extra check to make sure that our 524 // roundtrip time was less than our desired timeout 525 // for cases where that timeout is < 1000ms. 526 if (pEchoReply->Status == IP_SUCCESS 527 && (int)pEchoReply->RoundTripTime <= timeout) 528 { |