🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

stThreadBlocking Vs stNonBlocking confusion

#4501
From: Stefano Bonifazi
Date: Mon, 31 Jan 2005 20:09
40 lines
3234 bytes
Hi All!
 Maybe I should post this thread in the students forum as it's a basic 
question ...
I always used "stNonBlocking" servers quite easily reading data from the 
clients in the OnClientRead event handlers, and sending data to them 
wherever I needed, without worrying about the OnClientWrite Event at all.
About  "stThreadBlocking" I could get the following news:
From a tutorial on the borland site ( Creating a threaded socket server and 
client application ) I see I should use the TWinSocketStream'  and create my 
own Threads and do all the stuff in the their ClientExecute method...
From the BCB Help I read: "The thread for each connection generates 
OnClientRead or OnClientWrite events when the server socket needs to read or 
write." so maybe I could continue to use the common OnClientRead for reading 
being aware that many of those handlers could be executed at the same time, 
so problems with "shared variables" could arise, while I should use the 
OnClientWrite when I need to write to the clients.
Finally I learnt from  a Mr Gambit's previous answer that I could easily 
reuse the code of "stNonBlocking" servers with "stThreadBlocking" ones 
calling Application->ProcessMessages() within the read loop (but what about 
the sending stuff then?)
But my confusion starts from how they work and when I should use a 
"stThreadBlocking" instead of "stNonBlocking" server.
On BCB Help I can read:
"When ServerType is stNonBlocking, all client connections are handled in a 
single execution thread by default", but does not this mean that all other 
sockets have to wait until the server finishes to execute the OnClientRead 
of the current socket? If so why not  this kind of server is called 
"blocking" instead?
If I need a server that sends big files to many clients what kind of server 
should I use?
If the server should send big files to few clients?
And many small packets to many clients?
Why should I use the threaded way for a TClientSocket? It has to manage only 
one connection, so why to make it threaded? To lighten the program's main 
thread burden?
 I hope that here I can find someone able to answer to my doubts, cause all 
books and articles I could find only  increased my confusion :(
 Thank You very much in advance!
Stefano B.
 
Technical Details
Message-ID: <41fe906e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,4f7607071b9a8537,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Stefano Bonifazi" <stefboombastic@email.it>
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: stThreadBlocking Vs stNonBlocking confusion
Date: Mon, 31 Jan 2005 21:09:19 +0100
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 212.141.200.118
Message-ID: <41fe906e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1107202158 212.141.200.118 (31 Jan 2005 12:09:18 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail