RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TServerClientThread.ClientExecute Method

Simulates OnClientRead and OnClientWrite events for the associated server socket.

Pascal
procedure ClientExecute; virtual;
C++
virtual __fastcall ClientExecute();

TServerClientThread calls ClientExecute from its Execute method. ClientExecute checks whether there is any information to read from the associated socket connection, and if so, simulates an OnClientRead event on the associated server socket. If there is no information sent from the client, ClientExecute simulates an OnClientWrite event. 

Because the server socket that receives these events is not local to the thread, the events occur within the main VCL thread using the Synchronize method. This method can be too slow if the server socket has many client connections, because each thread must wait for any other thread to finish reading or writing. When a server socket receives many client connection requests, override ClientExecute to handle the reading or writing using a thread-local instance of TWinSocketStream. In the ClientExecute method, be sure to check the Terminated property periodically.

Note: Do not use the properties and methods of global objects directly in the ClientExecute method. Instead, separate the use of objects that are not thread-local into a separate procedure call, and call that procedure by passing it as a parameter to the Synchronize method.
 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!