Here is my code:

if(pingerCount)
                pingers = new ::TPingThread*[pingerCount];

        for(int i = 0; i < pingerCount; ++i)
        {
                pingers[i] = new ::TPingThread(True);   // create suspended

                PingAddThread(pingers[i]->ThreadID);      // keep threadid 
so it's freed
                pingers[i]->FreeOnTerminate = true;
                //pingers[i]->PingId = pingers[i]->succ(I);            // 
keep track of the results
                pingers[i]->OnTerminate = PingThreadTermPing;    // where we 
get the response
                pingers[i]->PingHostName = targetServers->Strings[i];  // 
host name or IP address to ping
                pingers[i]->PingTimeout = 4000;           // ms
                pingers[i]->PingTTL = 32;                 // hops
                pingers[i]->PingLookupReply = false;      // don't need 
response host name lookup
                pingers[i]->Resume();                        // start it now
        }

...

void __fastcall httpServerThread::PingThreadTermPing(TObject *Sender)
{
        if(Terminated)
                return;

        unsigned int pingTimeInt;
        if(((TPingThread*)Sender)->ReplyTotal != 0)
        {
                pingTimeInt = ((TPingThread*)Sender)->ReplyRTT;
        }
        else
        {
                pingTimeInt = 4096;
        }
}

I noticed this unit ten days ago and it took my 2 hours to translate.

HTH,

SZ

----- Original Message ----- 
From: "Enrique" <[EMAIL PROTECTED]>
To: <twsocket@elists.org>
Sent: Monday, February 13, 2006 2:31 PM
Subject: [twsocket] Fast Pings ! Delphi->BCB


> Thanks Francois, but I'm still having problems with Delphi :-(
> How should I translate this?
> //--------------------------------
> for I := 0 to Pred (T) do
>    begin
>        if HostNames.Lines [I] <> '' then
>        begin
>            with TPingThread.Create (True) do   // create suspended
>            begin
>                PingAddThread (ThreadId) ;      // keep threadid so it's
> freed
>                FreeOnTerminate := True;
>                PingId := succ (I) ;            // keep track of the 
> results
>                OnTerminate := PingThreadTermPing ;    // where we get the
> response
>                PingHostName := HostNames.Lines [I] ;  // host name or IP
> address to ping
>                PingTimeout := 4000 ;           // ms
>                PingTTL := 32 ;                 // hops
>                PingLookupReply := false ;      // don't need response host
> name lookup
>                Resume ;                        // start it now
>            end ;
>        end;
>    end ;
> //--------------------------------
> I cannot understand completely these parts:
> for I := 0 to Pred (T) do    ->    (Pred(T)?????)
> with TPingThread.Create (True) do   // create suspended    -> TPingThread*
> PingThread = new TPingThread(true);??? I must delete it later?
>
> And...
> StrPas (HostEnt^.h_name) ; -> HostEnt^.h_name?????
>
> SetLength (PingThreadList, Succ (Length (PingThreadList))) ;  -> I can't
> find PingThreadList, (Succ??)
>
>
> Thanks again !!!
> enri.
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to