🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

how to write receiving thread correctly (Indy)

#2544
From: Boris Epel
Date: Fri, 24 Mar 2006 07:21
20 lines
1515 bytes
Hi All,
I am writing a network application using Indy (BCB 6). I want to 
transfer messages of the type {int size; ....; char *data_of_this_size}.
The receiving thread looks like this:

while(!Terminated && Client->Connected())
{
      Client->ReadBuffer(block->Header, 22);
      if(block->Decode(block->Header, 22))  // convert received buffer 
to  e.g. size
       {
         Client->ReadBuffer(block->Buffer, block->Size);
         ...;
       }
}
the problem is that this code is obviously block the thread when I want 
to shutdown application

Is there better way to write the receiving thread ?
Boris
Technical Details
Message-ID: <44239df4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.gamma.ru!Gamma.RU!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,781e876beb7d3f81,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Fri, 24 Mar 2006 08:21:26 +0100
From: Boris Epel <boep777@yahoo.com>
User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: how to write receiving  thread correctly (Indy)
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 212.144.29.46
Message-ID: <44239df4$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1143184884 212.144.29.46 (23 Mar 2006 23:21:24 -0700)
Lines: 20
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.gamma.ru!Gamma.RU!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail