🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Indy TCP C/S: Timeout , Concurrent access, Number of threads

#3296
From: Remy Lebeau (TeamB)
Date: Thu, 06 Oct 2005 19:49
61 lines
2910 bytes
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> wrote in message
news:43456cbf@newsgroups.borland.com...

> I'm using Indy that was shipped with BCB6

Then you are using Indy 8, which is an outdated version that is no longer
supported.  Please go to Indy's website (http://www.indyproject.org) and
upgrade to Indy 9 or 10.

> What am I doing wrong? I thought it's Indy 9!

No, it is not.  It is Indy 8.

> Why you are using LockList/UnlockList?

Because the Threads property is a TThreadList, which is a TList that is
protected by a critical section.  You have to lock the critical section in
order to access the TList for any reason.

> I thought that ONE 'Connect()' on client side triggers
> ONE 'OnExecute()' on server side...

Nope.  OnExecute is triggered in a loop inside of TIdTCPServer, ie:

    TIdPeerThread::Run()
    {
        //...
        while( !Stopped )
            OnExecute(this);
        //...
    }

You can use the TIdPeerThread's Connection property to know which client is
triggering the event handler at the time.

> But now, when I re-think, it's obvious that *cannot* be
> possible - that I say on client side:
>
>    WriteInteger()
>    WriteString()
>
> ...and expect that *only* ONE OnExecute() is trigered.

That is not what I meant.  Individual writing operations do not trigger
their own OnExecute events.  When the OnExecute event is triggered, you read
everything you need from it, and then exit.  The OnExecute is then looped,
waiting for you to read more data when ready.

> But is it true that ONE Write...() trigeres ONE OnExecute()?

No.

> Yes, I was aware of that... I just wanted to resolve major
> problems first...

Thread safety is a major problem.  You can deadlock or crash the server if
your code is not thread-safe.


Gambit
Technical Details
Message-ID: <4345808b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!cyclone.bc.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <434503e6$1@newsgroups.borland.com> <43455dd4$1@newsgroups.borland.com> <43456cbf@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,cf1d5664f47b34d3
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: <434503e6$1@newsgroups.borland.com> <43455dd4$1@newsgroups.borland.com> <43456cbf@newsgroups.borland.com>
Subject: Re: Indy TCP C/S: Timeout , Concurrent access, Number of threads
Date: Thu, 6 Oct 2005 12:49:10 -0700
Lines: 63
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: <4345808b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1128628363 68.69.17.41 (6 Oct 2005 12:52:43 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!cyclone.bc.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail