🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Would Indy's TIdTCPServer have any problem with connections I never read from?

#1978
From: Lesley Anne
Date: Thu, 31 Aug 2006 19:48
54 lines
3795 bytes
> OnException is triggered in the context of the connection's thread.
> OnListenException is triggered in the context of the thread that
> TIdTCPServer creats for a particular Binding that is listening for
> incoming connections.
> ...
> In Indy 9, simply derive from TIdPeerThread and then set the server's
> ThreadClass property before activating the server.  TIdPeerThread is a
> TThread descendant, so you have access to its Synchronize() method.
> ...
> Alternatively, derive from TIdSync instead of TIdPeerThread/TIdContext,
> and override the virtual DoSynchronize() method.

Thanks again for the explanation and examples.  The first method you 
discussed, making a TIdPeerThread descendant, was clearer (maybe just 
because it's more similar to other thread handling that I've done before). 
I'd like to use that method, but it only seems to take care of the 
TIdPeerThread cases.  Since OnListenException takes place in the context of 
a TIdListenerThread instead, would it not work there?

In your TIdSync descendant, I kind of got lost on what ended up happening to 
the string.  It had been loaded into Sync->FStr when you got to the line:
   Sync->Synchronize();
but then I'm not entirely sure how to make Synchronize() do anything with 
it.  At some point it needs to reach my form where I can display it.  So 
would that go with something like:

    void __fastcall TMySync::DoSynchronize()
    {
        Form1->HandleStringInput(FStr);
    }

and:

    void __fastcall TForm1::HandleStringInput(AnsiString Message)
    {
        Memo1->Lines->Add(Message);
    }

(Actually, if I'm understanding this correctly, those could be combined into 
just the DoSynchronize method, but I prefer keeping them separate just to 
let TForm1 be where the decision is made of what to do with the message.  I 
think it looks clearer that way.)

Is that how this works, or am I (yet again) looking at this completely 
wrong.  Basically, will Sync->Synchronize() take care of whatever it needs 
to do to make sure the threads actually are in synch, then call my 
DoSynchronize() function in a context where it's safe to do so?

(Part of my problem in understanding this is that I don't really understand 
quite what Synchronize() does in the first place.  I know that it's 
necessary, and a bit about why and when it's necessary, but that's about as 
far as I got in understanding it.  Not quite knowing how it does what it 
needs to makes me a bit leery of overriding anything too closely connected 
with it.)
Technical Details
Message-ID: <44f73d33$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44f480ff@newsgroups.borland.com> <44f49d01$1@newsgroups.borland.com> <44f5c67a$1@newsgroups.borland.com> <44f5e682$1@newsgroups.borland.com> <44f5ef4f@newsgroups.borland.com> <44f6068c$1@newsgroups.borland.com> <44f70595$1@newsgroups.borland.com> <44f71c6c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,c51ec25c5d4e68e1
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Lesley Anne" <mspfila-ng@yahoo.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <44f480ff@newsgroups.borland.com> <44f49d01$1@newsgroups.borland.com> <44f5c67a$1@newsgroups.borland.com> <44f5e682$1@newsgroups.borland.com> <44f5ef4f@newsgroups.borland.com> <44f6068c$1@newsgroups.borland.com> <44f70595$1@newsgroups.borland.com> <44f71c6c$1@newsgroups.borland.com>
Subject: Re: Would Indy's TIdTCPServer have any problem with connections I never read from?
Date: Thu, 31 Aug 2006 15:48:59 -0400
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 144.160.5.25
Message-ID: <44f73d33$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1157053747 144.160.5.25 (31 Aug 2006 12:49:07 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail