🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1981

Re: help with Indy Telnet

#1981
From: Andre' Burke
Date: Fri, 01 Sep 2006 06:22
73 lines
3873 bytes
Bob,

I follow what you are saying but in this case I dont think thats the 
problem.

I write events to a log file (most of which I stripped out of the example 
code to simplify things.
The log file shows that I send the request for data an 10-12 seconds later 
the program times out with the message:

"No data recieved for 10 counts"

I can then see it going into the MyDisconnect function and calling the 
disconnect.
I write a log message right before and directly after the actual diconnect 
call and the log file shows the one before it and nothing after that.

In fact I have added another timer to the form that simply fires once a 
second and writes the state of the original timer to the log file, eg 
whether it is enabled or not.
Even this extra timer stops at this point.

I originally had a similar problem when I tried to disconnect from inside 
the OnDataAvailable event.
Looking in the delphi source for the Telnet component I figured out that 
this was causing a deadlock as the mainthread was waiting for the connection 
thread to terminate which was stuck inside the OnDataAvailable method also 
waiting for itself to terminate.

This seems to be something similar, except that the disconnect is now no 
longer being called in the OnDataAvailable method but rather in the timer.

It seems as if the Telnet component recieves the incoming data, but for some 
reason gets stuck and doesnt call the OnDataAvailable method.  When I then 
try and disconnect the disconnect method waits for the connection thread to 
terminate (which is stuck) so it never returns, thus locking up the main 
thread (from which the disconnect was called).

A work-around for this *might* be to spawn my own thread in which to call 
the disconnect.
But then I will have the problem of killing this new thread if it should get 
locked up with the telnet component.
And of course it could introduce extra complexity in my own code with shared 
data and critical sections etc. etc.

Make any sence?  Or I am on the wrong track here completely?

Andre'




"Bob Gonder" <notbg@notmindspring.invalid> wrote in message 
news:adsdf2dk8k4s0tefv5r49fi67ghjs6rlmt@4ax.com...
> Andre' Burke wrote:
>
>>I would greatly appreciate any advice.
>
> 2 suggestions:
>
> 1) Don't rely on _finally catching a return;
> There is a "bug" with _finally and return.
> In this case, if it hits, your timer stays Off.
>
> 2) Restucture your code
> If "state" is a state machine, it might be clearer to use a
> switch(state) with the cases in state-order.
> Added benefit: breaking out of the switch allows you to drop to the
> _finally and timer-enable, no internal returns needed.
>
> At the very least, restart the timer before every return statement,
> and see if things don't improve.
> 
Technical Details
Message-ID: <44f7d1ac$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <44f68cef@newsgroups.borland.com> <44f6917c$1@newsgroups.borland.com> <44f69c27@newsgroups.borland.com> <adsdf2dk8k4s0tefv5r49fi67ghjs6rlmt@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,3d66693bd859a203
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Andre' Burke" <no.spam@spam.no>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <44f68cef@newsgroups.borland.com> <44f6917c$1@newsgroups.borland.com> <44f69c27@newsgroups.borland.com> <adsdf2dk8k4s0tefv5r49fi67ghjs6rlmt@4ax.com>
Subject: Re: help with Indy Telnet
Date: Fri, 1 Sep 2006 08:22:30 +0200
Lines: 75
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 196.38.124.67
Message-ID: <44f7d1ac$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1157091756 196.38.124.67 (31 Aug 2006 23:22:36 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail