Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help using IcmpSendEcho2 asynchronously

661 views
Skip to first unread message

Jim464

unread,
Oct 4, 2007, 5:16:01 PM10/4/07
to
I have a need to use the IcmpSendEcho2 API command asynchronously using the
ApcRoutine callback routine.

I have used the IcmpSendEcho2 command successfully synchronously.

A question I have is what would the signature look like for the ApcRoutine
callback routine I need to define?

When I call IcmpSendEcho2 what would the third parameter look like?

I will need to send many IcmpSendEcho2 requests at one time. How will the
callback ApcRoutine know which IcmpSendEcho2 call is done. I guess this is
where the ApcContext parameter comes into play?

I can't find any example code on MSDN or elsewhere that demonstrates how to
use the IcmpSendEcho2 command asynchronously.

Farooque Khan

unread,
Oct 5, 2007, 8:40:13 AM10/5/07
to
Here's an example:

----------------
int ReplyCame(PVOID param)
{
char* szAddr = (char*) param;

printf("Replay Came for %s......\n", szAddr);

return 0;
}

char* szAddr1 = "172.18.1.1";
char* szAddr2 = "172.18.1.4";

int _tmain(int argc, _TCHAR* argv[])
{
char *SendData = "Data Buffer";
LPVOID ReplyBuffer;

HANDLE IcmpHandle = IcmpCreateFile();

IPAddr addr1 = inet_addr(szAddr1);
IPAddr addr2 = inet_addr(szAddr2);

ReplyBuffer = (VOID*) malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData));

IcmpSendEcho2(IcmpHandle, NULL, (FARPROC)ReplyCame, szAddr1, addr1,
SendData, sizeof(SendData), NULL, ReplyBuffer, 8*sizeof(ReplyBuffer) +
sizeof(ICMP_ECHO_REPLY), 1000);
IcmpSendEcho2(IcmpHandle, NULL, (FARPROC)ReplyCame, szAddr2, addr2,
SendData, sizeof(SendData), NULL, ReplyBuffer, 8*sizeof(ReplyBuffer) +
sizeof(ICMP_ECHO_REPLY), 1000);

SleepEx(5000, TRUE);

return 0;
}
----------------

--

Farooque Khan
Project Manager
Infospectrum India Pvt. Ltd.
faro...@info-spectrum.com
Phone: +91 712 229 3711
www.info-spectrum.com

This e-mail may contain confidential or proprietary information. If you are
not the intended recipient please notify the author by replying to this
e-mail and please note that use, disclosure, distribution, copying or
printing of this e-mail or its attachments is strictly prohibited and may be
unlawful. Whilst this e-mail has been checked for viruses, the sender takes
no responsibility and recipients are advised to undertake their own checks.


"Jim464" <Jim...@discussions.microsoft.com> wrote in message
news:BEBBB74B-E3E5-4D09...@microsoft.com...

Jim464

unread,
Oct 5, 2007, 1:58:03 PM10/5/07
to
Thank you for you reply! it was vey helpful.

A follow up question:

In the ReplayCame function I will need to call IcmpParseReplies to get the
result
of the IcmpSendEcho2 command. For the call to IcmpParseReplies I need to
pass in the ReplyBuffer. So the way I understand it, I would need to have
seperate RelayBuffers for each call to IcmpSendEcho2 The way your code is
written now, I would get two calls to RelayCame, but I could not check the
result of the IcmpSendEcho2 command because it is using the same buffer for
each call to IcmpSendEcho2. Is that correct ?

Farooque Khan

unread,
Oct 9, 2007, 10:08:25 AM10/9/07
to
Yes, that is correct. I just copied this sample from MSDN and modified for
async operation. The ReplayBuffer has to be different and may be, passed
back to ReplyCame() as the parameter (by providing in IcmpSendEcho2()) where
you then have to parse it.

HTH,

--

Farooque Khan
Project Manager
Infospectrum India Pvt. Ltd.
faro...@info-spectrum.com
Phone: +91 712 229 3711
www.info-spectrum.com

This e-mail may contain confidential or proprietary information. If you are
not the intended recipient please notify the author by replying to this
e-mail and please note that use, disclosure, distribution, copying or
printing of this e-mail or its attachments is strictly prohibited and may be
unlawful. Whilst this e-mail has been checked for viruses, the sender takes
no responsibility and recipients are advised to undertake their own checks.


"Jim464" <Jim...@discussions.microsoft.com> wrote in message

news:6D645196-415F-491B...@microsoft.com...

prashantwanjari

unread,
Apr 10, 2008, 2:41:05 AM4/10/08
to
Hi
can any please tell the how to implement IcmpSendEcho2 in vb.net , currently i am using IcmpSendEcho but its not working on timeout issue

need urgent help

Volodymyr M. Shcherbyna

unread,
Apr 10, 2008, 4:27:29 AM4/10/08
to
Your question is confusing. The function IcmpSendEcho2 is already
implemented, and exported by Iphlpapi.dll. If you need to use it in Visual
Basic .NET you probably has to use platform invoke (to import the function
from Iphlpapi.dll) to use it.

If you have differences with invoking function exported from UNmanaged dll,
you probably has to ask this question somewhere at VB .NET newsgroup.

--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
<prashant wanjari> wrote in message
news:20084102414pr...@yahoo.com...

0 new messages