🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #32436

Re: Thread sychronization

#32436
From: Martin James
Date: Fri, 22 Nov 2002 23:30
34 lines
2015 bytes
Ross Shaw <rossshaw@no_spampeakndt.com> wrote in message
news:3dde3943$1@newsgroups.borland.com...
> Hi,
>
> I am trying to create a blocking tcp client connection using the
TTcpClient
> component
> (using D7 pro) if in blocking mode I have to keep checking if data
it there,
> so I have
> created a worker thread when a connection is successful that checks
and
> reads in
> data this fires the OnReceive method with the data. It all works
but I am
> unsure about
> sychronization and if its ok to send data with the component when
the worker
> thread
> is checking / reading data.
>

I do this often with TidTCPClient.  No problem sending data from,
say, the main thread while the worker is waiting to read..  Your
stack-based buffer means that the onReceive event must be fired in
the thread context or using 'synchronize' or 'sendMessage'.  If you
want to use 'postMessage' or some other no-wait queueing mechansim,
you should use a new heap buffer each time.

Your timeout seems a little short,(10).  What do you do on timeout?

Rgds,
Martin
Technical Details
Message-ID: <3ddebeb4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-08!supernews.com!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mail
References: <3dde3943$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,2a3da90c101926b6
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2002-11-22 16:15:56 PST
From: "Martin James" <mjames_falcon@dial.pipex.com>
Newsgroups: borland.public.delphi.language.objectpascal
References: <3dde3943$1@newsgroups.borland.com>
Subject: Re: Thread sychronization
Date: Fri, 22 Nov 2002 23:30:12 -0000
Lines: 37
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
NNTP-Posting-Host: 62.188.17.70
Message-ID: <3ddebeb4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1038007988 62.188.17.70 (22 Nov 2002 15:33:08 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-08!supernews.com!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mail