Re:Blocking of messages
Quote
In article <3b3e4000_1@dnews>, George wrote:
> J'm writting an client-server application in Borland Delphi 5.0 and J'm
> using components ClientSocket and ServerSocket for communication beetween
> clients and server. Programs seemed to work smoothly, but suddenly I noticed
> something strange in server app.:
> -when appeared one after another two events OnClientRead during I was
> resizing or moving the server window, the program hunged up and stopped
> reacting for the user interface !
You should never use nonblocking sockets in a server application in my
opinion. This forces all processing of incoming socket data to the main thread
and will be a serious bottleneck if you ever have more than one client
connecting to the server at the same time. And as you noticed the socket data
events depend on processing messages. If you do something on the server that
blocks message processing in the main thread for some time you freeze the
clients as well. Sprinkling the code with ProcessMessages call will only make
the mess deeper. A server app using sockets needs to have a proper
multithreaded design, using blocking sockets and a separate thread for each
incoming connection. You use the serversockets OnGetThread event to create a
worker thread for a connection.
If you are new to threads i recomment this intro:
http://www.pergolesi.demon.co.uk/prog/threads/ToC.html
Peter Below (TeamB) 100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.