IcmpSendEcho() problem

BlitzMax Forums/BlitzMax Programming/IcmpSendEcho() problem

Scaremonger(Posted 2012) [#1]
Hi there,

I'm adding PING to another utility and I'm seeing something odd!

From the code I can ping 8.8.8.8 (Google I think) but I cannot ping my gateway or localhost. If I open a windows command prompt I can ping them but I cannot figure out why I cannot from my code.

Any suggestions?

Here is my test code (Windows Only):



BlitzSupport(Posted 2012) [#2]
I believe it's due to the byte order of the 'ip' integer, which is supposed to be in 'network byte order', or big-endian, rather than the current [x86] little-endian order.

This appears to work, but please test further!



I've simply added a function to flip the order of the ip bytes (borrowed from JoshK's Networking Library in the Code Archives) and used it twice, once when calling the echo command and again when parsing its results. I *think* it's right, but you should probably check, and check if it's needed elsewhere too...

(BTW, I think "lphlpapi.dll" should be "iphlpapi.dll".)


Scaremonger(Posted 2012) [#3]
That seems to be the solution; Many thanks and well spotted on the DLL name typo. That would have bitten me further down the line.

:)


Scaremonger(Posted 2012) [#4]
Just in case anyone else tries this code, I found a bug that causes exception errors. The following should fix it: