System.Win.ScktComp.TCustomServerSocket.OnClientConnect

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property OnClientConnect: TSocketNotifyEvent index 2 read GetOnClientEvent  write SetOnClientEvent;

C++

__property TSocketNotifyEvent OnClientConnect = {read=GetOnClientEvent, write=SetOnClientEvent, index=2};

Properties

Type Visibility Source Unit Parent
event protected
System.Win.ScktComp.pas
System.Win.ScktComp.hpp
System.Win.ScktComp TCustomServerSocket

Description

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

Write an OnClientConnect event handler to take specific action when a client socket completes the socket connection to the server socket. For example, the socket may start reading or writing over the connection in an OnClientConnect event handler.

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

  1. An OnListen event occurs just before the server socket is opened for listening.
  2. The server socket receives client requests in a listening queue. The server socket accepts one of those requests, and receives a Windows socket handle for the new socket connection.
  3. The server socket generates an OnGetSocket event, passing in the Windows socket handle. If a TServerClientWinSocket object for the server endpoint of the new connection is not created in an OnGetSocket event handler, the server socket creates one. The TServerWinSocket object continues to listen for other clients.
  4. An OnAccept event occurs, using the new TServerClientWinSocket object.
  5. If 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 server socket creates a TServerClientThread.
  6. If ServerType is stThreadBlocking, an OnThreadStart event occurs as the thread begins execution.
  7. The client completes the connection to the TServerClientWinSocket object and an OnClientConnect event occurs.

Note: If ServerType is stThreadBlocking, make sure that all code in an OnClientConnect event handler is thread-safe. Use the GetClientThread method of the Sender parameter to access thread-specific information.

Note: The OnClientConnect event handler for TServerSocket is also set when setting the OnClientConnect event handler of the associated TServerWinSocket.

See Also