hi all

this is my first post on the new forum!
nice new layout i have to say.
a great improvement.


is there a special API to ping a host?
or if there isnt, what is the best way to go about it?

also, how would i set a timeout in blocking-mode?

all response appreciated.
Posted on 2001-07-23 17:47:23 by skud
How to ping i dunno but to set a timeout in blocking mode you use select()

works like this:

sockset STRUCT
dwCount DWORD ?
dwSocket DWORD ?
sockset ENDS

mysocket SOCKSET <?>
timeout timeval <?>


invoke socket, ...
mov mysocket.dwSocket, eax
mov mysocket.dwCount, 1
mov timeout.tv_sec, 3
mov timeout.tv_usec, NULL


invoke send, ...

invoke select, NULL, addr mysocket, NULL, NULL, addr timeout
.IF eax==NULL ; timeout
invoke recv, ...

Just read up on select(), it's easy.
Posted on 2001-07-23 20:36:48 by Zynaps
Zynaps - thanks, i'll have a look at that.


what i actually want to achieve with pinging an ip address is to establish whether that address actually exists (ie. a host has obtained that ip address). it just occured to me that pinging might not be the best way to do this (i still want to know how to ping though :). in fact it probably isnt the best way. is it? would it be better to try and resolve the ip?... or another method?

Posted on 2001-07-24 04:12:27 by skud
There are some functions in the ICMP API (if I remember/spelled it correctly ;-), microsoft didn't documented them at first but they are available. In the latest PSDKs they are documented..
On my homepage is a link to a winsock faq, somewhere in that FAQ these functions are explained.

Posted on 2001-07-25 09:03:28 by Thomas
I've some VB declares for that API's. Never used them:

Declare Function IcmpSendEcho Lib "icmp.dll" (ByVal _
IcmpHandle As Long, ByVal DestinationAddress As Long, _
ByVal RequestData As String, ByVal RequestSize As _
Integer, ByVal RequestOptions As Long, ReplyBuffer As _
ICMP_ECHO_REPLY, ByVal ReplySize As Long, ByVal _
TimeOut As Long) As Long

Declare Function IcmpCreateFile Lib "icmp.dll" () _
As Long

Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal _
IcmpHandle As Long) As Long

I think you should be able to find some code on the net with the API names :alright:

P.S.: A description of the parameters:
Posted on 2001-07-25 09:48:20 by bazik
You can find lots of networking stuff with source code (not asm though) here:



Posted on 2001-07-25 10:14:39 by latigo
yes, you would normally use ICMP to do this but I haven't found libs+doc for masm :)... I've seen sources made in C++ of pings using ICMP and not using ICMP and I haven't tried started porting it in masm cause i don't have the libs plus it looked difficult for me to do :)... the sources are in www.stardust.com I think, I hope you port them, goodluck :)

Posted on 2001-07-27 10:02:00 by clip
You could access the API's with GetProcAddress
Posted on 2001-07-27 10:19:17 by bazik
I've put the ICMP lib, header and include on my site at exagone.cjb.net. The header file contains some documentation.

Posted on 2001-07-27 10:20:11 by Thomas