Server Events

From RAD Studio
Jump to: navigation, search

Go Up to Responding to Socket Events

Server socket components form two types of connections: listening connections and connections to client applications. The server socket receives events during the formation of each of these connections.

Events when listening

Just before the listening connection is formed, the OnConnecting event occurs.

Events with client connections

When a server socket accepts a client connection request, the following events occur:

  • An OnAccept event occurs, passing the new TTcpClient object to the event handler. Here you can use the properties of TTcpClient for the first time, to obtain information about the server endpoint of the connection to a client.
  • If TServerType is stThreadBlocking, an OnGetThread event occurs. If you want to provide your own customized descendant of ServerSocket, you can create one in an OnGetThread event handler, and that will be used instead of TServerSocket. In order to perform the initialization of the thread or to make a socket API call before the thread starts reading or writing over the connection, you will have to use the OnGetThread event handler for these tasks as well.
  • The client completes the connection and an OnAccept event occurs. With a non-blocking server, you can now start reading or writing over the socket connection.

See Also