RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TServerWinSocket.OnClientConnect Event

Occurs when a client socket completes a connection accepted by the listening socket.

Pascal
property OnClientConnect: TSocketNotifyEvent;
C++
__property TSocketNotifyEvent OnClientConnect;

Write an OnClientConnect event handler to take specific action when a client socket completes the socket connection to a TServerClientWinSocket object. Depending on the service, this is the point when the socket should begin reading or writing. 

The order of Windows server socket events leading up to OnClientConnect is as follows: 

1An OnSocketEvent event of type seListen occurs just before the Windows socket is opened for listening. 

2The listening Windows socket receives client requests in a listening queue. The listening socket accepts one of those requests, and receives a Windows socket handle for the new socket connection. 

3The listening socket generates an OnGetSocket event, passing in the Windows socket handle. If a TServerClientWinSocket object for the Windows socket handle was not created in the OnGetSocket event handler, the Windows socket creates one. The Windows socket continues to listen for other clients. 

4An OnSocketEvent event of type seAccept occurs, using the new TServerClientWinSocket object. 

5If ServerType is stThreadBlocking and no thread is available in the cache, an OnGetThread event occurs. If the OnGetThread event handler does not create a thread, the Windows socket object creates a TServerClientThread

6If ServerType is stThreadBlocking, an OnThreadStart event occurs as the thread begins execution. 

7The client completes the connection to the TServerClientWinSocket object and an OnClientConnect event occurs. 

The Sender parameter is the TServerWinClient object that listens for client requests. The Socket parameter is the TServerClientWinSocket object that forms a connection to the client socket.

Note: If ServerType is stThreadBlocking, make sure that all code in an OnClientConnect event handler is thread-safe. Use the GetClientThread method to access thread-specific information.
Note: The OnClientConnect event handler for TServerWinSocket is also set when setting the OnClientConnect event handler of the associated TServerSocket.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!