Re: Problem with Telnet clients

Giganews Newsgroups
Subject: Re: Problem with Telnet clients
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Thu, 10 Feb 2005

"A. Stern" <ahCUT…@CUTvtr.net> wrote in message
news:Xns95FA37971E71ahcsvtrn…@206.123.68.233...

> I'm using BCB 6.0 Enterprise Suite with Indy 8.0.25 on Windows 2000.

That is a very old version of Indy.  You should seriously consider
upgrading.

>    AnsiString IP;
>    IP = CuLAMainForm->UnsoModList->Strings[ModemIdx*5];
>    IP.Delete(1,3);

That code is not thread-safe.  You should be using TThread::Synchronize() to
access the main thread objects in a thread-safe manner.

>    ATelnetClient->OnDataAvailable = &ATelnetClientOnDataAvailable;

By default, the OnDataAvailable event is triggered via a call to
TThread::Synchronize().

>    while(ATelnetClient->Connected()){};

That loop is too tight.  It does not yield CPU cycles to other threads.
That could be causing some of your problems, especially if Synchronize() is
not able to execute the OnDataAvailable code in a timely fashion.  You
should put a call to Sleep() in the loop:

    while( ATelnetClient->Connected() )
        Sleep(1000);

Gambit

Replies

In response to

Problem with Telnet clients posted by A. Stern on Thu, 10 Feb 2005