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

IcmpSendEcho works first time, but hangs every time after

246 views
Skip to first unread message

Curtis Coleman

unread,
Aug 15, 2002, 7:34:01 PM8/15/02
to
I'm adding ping capabilities to a control panel application using
icmplib.lib, since sockets can't be opened in raw mode in WinCE 3.0.
When the app starts, I call WSAStartup and then IcmpCreateFile. Then
when the user has picked the destination and timeout, they click the
send button, which results in a call to IcmpSendEcho. The very first
time, everything works fine: the ping is sent out, a reply is
received, and IcmpSendEcho returns. However, every time after that,
IcmpSendEcho just seems to block forever, and nothing is sent. If I
shut down the app (calling IcmpCloseHandle and WSACleanup) and restart
it, IcmpSendEcho will always block. The only way to get it to work
again is to reset the device (iPAQ 3835).

Has anybody ever seen this happen? Any thoughts on what I might be
doing wrong?

Thanks,
Curt


BTW, here's how I'm calling IcmpSendEcho:

********************

#define PING_BUFFER_SIZE 8192
#define DEFAULT_ECHO_DATA_LENGTH 32

...

BYTE aPingSendBuffer [ PING_BUFFER_SIZE
] ;
BYTE aPingReplyBuffer [
PING_BUFFER_SIZE ] ;
HANDLE hICMP ;

...

dwReplyCount = IcmpSendEcho ( hICMP,
nDestination,
aPingSendBuffer,
DEFAULT_ECHO_DATA_LENGTH,
NULL,
aPingReplyBuffer,
PING_BUFFER_SIZE,
pPingInfo->dwTimeout * 1000 ) ;

********************

Paul G. Tobey

unread,
Aug 16, 2002, 12:28:15 PM8/16/02
to
I don't have immediate access to a CE 3.0 platform to try it on, but CE.NET
works just fine when opening the ICMP handle once, then sending multiple
packets using IcmpSendEcho. After all, that's the way the PING sample
program works, too. If I were to guess, I'd say that either you are setting
some send option the second time around that wasn't set before, or freeing
something, causing things not to work.

Paul T.

"Curtis Coleman" <Curtis....@viasat.com> wrote in message
news:42464606.0208...@posting.google.com...

Chris Weingarth

unread,
Sep 4, 2002, 4:41:20 PM9/4/02
to
Hi,
I don't know if you have solved this problem or not yet but I have some
code that works for me.
This function returns a TRUE if the ping was successful and FALSE if not.

BOOL CEnetComm::Ping(DWORD ipaddress)
{
char acPingBuffer[64];
BOOL retVal = FALSE;
char pIpe[1024];
DWORD dwStatus;

HANDLE hIP = IcmpCreateFile();

if (hIP == INVALID_HANDLE_VALUE)
{
AfxMessageBox(_T("Unable to open ping service."));
retVal = FALSE;
}
else
{
// Build ping packet
memset(acPingBuffer, '\xAA', sizeof(acPingBuffer));

dwStatus = IcmpSendEcho(hIP, htonl(ipaddress),
acPingBuffer, sizeof(acPingBuffer), NULL, pIpe,
1024, 2000); // hard coded timeout of 2 seconds

if ( dwStatus == 0 )
retVal = FALSE; // failure
else
retVal = TRUE; // success

IcmpCloseHandle(hIP);
}

return retVal;
}
Hope this helps.
Chris

0 new messages