System.Win.ScktComp.TServerClientThread.ClientExecute

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure ClientExecute; virtual;

C++

virtual void __fastcall ClientExecute();

Properties

Type Visibility Source Unit Parent
procedure
function
protected
System.Win.ScktComp.pas
System.Win.ScktComp.hpp
System.Win.ScktComp TServerClientThread

Description

Simulates OnClientRead and OnClientWrite events for the associated server socket.

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.

See Also