user1174133
user1174133

Reputation: 13

C++ Embarcadero TTcpServer and TTcpClient

I want to know how to work with connected clients on TTcpServer class? I got a client connected on method "ServerAccept" whats next? How can i work with them? I need to start from ServerAccept a new thread to work with socket client?

Upvotes: 0

Views: 2147

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596407

The TTcpServer.OnAccept event is triggered when the TTcpServer.Accept() method is called and a client is accepted. ALL socket work with that client has to be done within the context of the TTcpServer.OnAccept event, using the methods of the TCustomIpClient object that is provided by the event. As soon as the event handler exits, TTcpServer closes the connection. If the TTcpServer.BlockMode property is set to bmThreadBlocking, the OnAccept event handler runs in a thread managed by TTcpServer so you do not need to create your own thread. Otherwise, you need to call the TTcpServer.Accept() method in your own code, in which case you can call it in your own thread if desired.

Upvotes: 2

Related Questions