RAD Studio
ContentsIndex
PreviousUpNext
Server 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.

Just before the listening connection is formed, the OnListening event occurs. You can use its Handle property to make changes to the socket before it is opened for listing. For example, if you want to restrict the IP addresses the server uses for listening, you would do that in an OnListening event handler.

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

  • An OnAccept event occurs, passing in the new TTcpClient object to the event handler. This is the first point when you can use the properties of TTcpClient to obtain information about the server endpoint of the connection to a client.
  • If BlockMode is bmThreadBlocking an OnGetThread event occurs. If you want to provide your own customized descendant of ServerSocketThread, you can create one in an OnGetThread event handler, and that will be used instead of TServerSocketThread. If you want to perform any initialization of the thread, or make any socket API calls before the thread starts reading or writing over the connection, you should 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 may want to start reading or writing over the socket connection at this point.

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