Article View: borland.public.cppbuilder.internet.socket
Article #4581Re: [Indy 9.018 / CBuilder6] IdTCPServer Connection always NULL
From: Remy Lebeau (TeamB)
Date: Fri, 14 Jan 2005 18:54
Date: Fri, 14 Jan 2005 18:54
29 lines
2201 bytes
2201 bytes
"Zoetjuh" <peter@i-hate-spam.zoetjuh.demon.nl> wrote in message
news:41e80f47@newsgroups.borland.com...
> void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread)
> {
> ShowMessage( AThread->Connection->ReadLnWait(100) );
> }
Do not use ShowMessage() like that. The OnExecute event is triggered in the
context of a worker thread, not the main VCL thread. ShowMessage() displays
a VCL form, which will not work property from any thread other than the main
VCL thread because the VCL is not thread-safe. Use MessageBox() instead,
which is thread-safe.
Also, it looks like you are trying to specify a timeout value to
ReadLnWait(), is that correct? IF so, then you need to use ReadLn() instead
of ReadLnWait(), as ReadLnWait()'s parameter is not a timeout to begin with.
> However, nomatter what I try, The "Connection" is always NULL.
That is not possible. The Connection property is valid for the lifetime of
the socket that is bound to the TIdPeerThread. There is no way for
OnExecute to trigger with a NULL Connection property. The Connection is
assigned before OnExecute is triggered for the first time, and not freed
until OnExecute is triggered for the last time. There is no in-between.
Gambit
Technical Details
Message-ID:
<41e81519$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!logbridge.uoregon.edu!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41e80f47@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,8d17184a33491515 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <41e80f47@newsgroups.borland.com> Subject: Re: [Indy 9.018 / CBuilder6] IdTCPServer Connection always NULL Date: Fri, 14 Jan 2005 10:54:42 -0800 Lines: 31 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <41e81519$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1105728793 68.69.17.41 (14 Jan 2005 10:53:13 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!logbridge.uoregon.edu!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail