Board index » delphi » IdIcmpClient vs. Multi-thread Application

IdIcmpClient vs. Multi-thread Application

Hi there!

Need help with following problem:

I use IdIcmpClient to Ping remote computers. Normally everything works quite
well, but if I use IdIcmpClient simultaneously in multiple threads, it
doesn't work as well.

PLEASE HELP ME!
Thanx for ideas ...

~ [MiCRO Developer] ~

 

Re:IdIcmpClient vs. Multi-thread Application


Quote
"MiCRO Developer" <mi...@obta.sk> wrote in message

news:3e863ae1@newsgroups.borland.com...

Quote
> I use IdIcmpClient to Ping remote computers. Normally everything works
quite
> well, but if I use IdIcmpClient simultaneously in multiple threads, it
> doesn't work as well.

Are you using Indy 9?  One of the modifications made in Indy 9 is to send a
request identifier in Ping to allow this type of use.

Here's an unpublished update to the Indy 9 help topic for Ping:

==========
Summary:

Sends an echo request and receives an echo response.

Parameters:

ABuffer - Optional data to be sent in the ping request.
SequenceID - Uniqueness Identifier for the Ping request. Default value is 0.

Description:

Ping is a procedure used to prepare and send an echo request datagram, and
to receive the echo response. Ping sends the echo request to the computer
identified in Host, and gets the response to the echo request datagram.

ABuffer is an optional string that contains values to be sent in the content
of the Ping request.

SequenceID is a Word value used as a packet identifier for the Ping request.
SequenceID is also used when decoding the response packets for a Ping
request. When SequenceID contains a non-zero value, it is used to match an
echo response to the original ping request with the same sequence identifer.
SequenceID can be set to a unique value to identify a specific Ping request
and/or response.

Set ReceiveTimeout to indicate the time to wait for a response to the echo
request datagram.

Use ReplyStatus to access identification, diagnostic, and statistical
information received in a response to an echo request datagram.

Assign an OnReply event handler to perform additional processing when a
TOnReplyEvent is triggered during processing for a Ping response.

The socket handle allocated for sending and receiving datagram packets in
Ping is closed prior to completion of the method.

Note: For Windows NT and Windows 2000, administrator privileges are required
to allow TIdICMPClient.Ping to work properly. The command line PING
application does not exhibit this behavior because Microsoft chose to use
undocumented calls in ICMP.DLL and its winsock implementation to get around
the issue. In short: they cheated. Indy does not use ICMP.DLL to maintain
Linux compatibility, and allow use of both Raw sockets and ICMP sockets.

See Also:

Host

ReceiveTimeout

ReplyStatus

OnReply

TOnReplyEvent

==========

hth...

--
Don

Join the Indy Docs project! (http://www.indyproject.org/teams/docs)

ELKNews - Get your free copy at http://www.atozedsoftware.com

Re:IdIcmpClient vs. Multi-thread Application


I use Indy9 but it doesn't work. (weird)

[btw] I use WinXP Pro EN v2002, Delphi7 Enterprise

~ [MiCRO Developer] ~

Re:IdIcmpClient vs. Multi-thread Application


Quote
> I use IdIcmpClient to Ping remote computers. Normally everything works
quite
> well, but if I use IdIcmpClient simultaneously in multiple threads, it
> doesn't work as well.

I had the same problem, i wanted to ping a remote computer several times and
at the same time, trace an ip.
I solved the problem ;).
Just don't use only one IdIcmpClient for mutiple threads.
I use one IdIcmpClient for pinging and one for tracing, seems that an
IdIcmpClient can't do 2 things at a time.
So just use multiple IdIcmpClient components.
1 IdIcmpClient for 1 thread.
Mhh i think it takes more memory but, what to do else?

Pliz let me know if it works.

cya
--
Douglas Quaid

Re:IdIcmpClient vs. Multi-thread Application


I use a unique IdIcmpClient in each thread. Each thread has the same
purpose: to ping remote computer.
(I use multiple thread because I need to ping more computers at the time)

[btw] I also generate unique SequenceID in each call.
I really do not understand why it doesn't work.

~ [MiCRO Developer] ~

Re:IdIcmpClient vs. Multi-thread Application


Quote
MiCRO Developer <mi...@obta.sk> wrote in message

news:3e87304d$1@newsgroups.borland.com...

Quote
> I use a unique IdIcmpClient in each thread. Each thread has the
same
> purpose: to ping remote computer.
> (I use multiple thread because I need to ping more computers at the
time)

> [btw] I also generate unique SequenceID in each call.
> I really do not understand why it doesn't work.

It's a problem/feature with the protocol.  ICMP has no connections &
socket-pairs, so Indy/winsock has no way of telling, from the basic
gnip reply, which thread initiated the call.   This is why the
replies get mixed up & idPing instances get gnips for pings sent by
other instances.  This is surely your problem - when I saw this
happening I assumed, nauturally, that my code was to blame & spent
ages debugging before someone in this group put me out of my misery.

I dodged the problem by using ICS for my pings.  It uses the M$
Icmp.dll which sorts out the gnips using the sequence data, as
mentioned by others.

Rgds,
Martin

Re:IdIcmpClient vs. Multi-thread Application


Thank you!

Other Threads