I have been looking at using IcmpSendEcho
, and found that it will fail to ping certain devices (e.g. my BT Home Hub 4) with GetLastError
reporting 11010. While for other devices it works fine (when executing on the same system). In comparison, ping.exe
succeeds on all these devices, but I have no idea how the implementation of Ping
differs. All cases I have tried so far have been IPv4, which I provided directly (so no DNS etc.).
hIcmpFile = IcmpCreateFile();
ipAddress = inet_addr(ipAddressStr);
...hIcmpFile is reused
static const WORD sendSize = 32;
static const DWORD replySize = sizeof(ICMP_ECHO_REPLY) + sendSize;
char sendData[sendSize] = { 0 };
char replyBuffer[replySize];
auto ret = IcmpSendEcho(hIcmpFile, ipAddress, sendData, sendSize, NULL, replyBuffer, replySize, 1000);
if (ret == 0)
{
auto error = GetLastError();
The only other report I have found is what would cause ICMPsendEcho to fail when ping.exe succeeds. However those answers appear to differ from my problem. I have tried using different payload sizes, and I have tried IcmpSendEcho2
, that also failed for the same devices.