Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Dec : Threading TIdIcmpClient & Matching Responses
| Subject: | Threading TIdIcmpClient & Matching Responses |
| Posted by: | "Ivor Flannery" (iflann..@7-11.com) |
| Date: | 27 Dec 2005 13:40:18 |
I am sending a bunch of pings using the TIdIcmpClient class and I'm
wondering how the packets are matched back up to the sender on the
reply. I am seeing failures sometimes when I don't expect to.
The basic premis is I have about 20000 addresses to periodically ping.
So I have a simple app that instantiates an TIdIcmpClient in a thread.
Here is a clip.
APing := TPingThread.Create(True);
Inc(ThreadCount);
APing.ListItem := AAddressPointer;
APing.Host := AHost;
APing.Msg := 'PING_TO_'+Ahost;
APing.OnTerminate := ThreadDone;
The worker thread is very simple. Setup the object and its vars and do
the ping. I use the ThreadID as a unique sequence number for the
request. In the ThreadDone procedure (assigned in main thread), I use
the record data pointed to by APing.ListItem to match up the original
request and store the reults.
AAddressItem := APing.ListItem;
AAddressItem.AddressUp := (APing.Result = 0);
AAddressItem.LastRtt := APing.RTT;
Dec(ThreadCount);
If I run 50 threads I don't seem to get ping failures. If a run 100
simultaneous threads then I get a couple. If I run 500 I get a bunch of
them. The response message from the client is a timeout condition.
I would appreciate any pointers. TIA
Ivor
--