简体   繁体   English

C ++ Embarcadero TTcpServer和TTcpClient

[英]C++ Embarcadero TTcpServer and TTcpClient

I want to know how to work with connected clients on TTcpServer class? 我想知道如何在TTcpServer类上使用连接的客户端? I got a client connected on method "ServerAccept" whats next? 我有一个客户端连接方法“ServerAccept”接下来是什么? How can i work with them? 我该如何与他们合作? I need to start from ServerAccept a new thread to work with socket client? 我需要从ServerAccept开始一个新的线程来使用套接字客户端?

The TTcpServer.OnAccept event is triggered when the TTcpServer.Accept() method is called and a client is accepted. TTcpServer.OnAccept TTcpServer.Accept()方法并接受客户端时,将触发TTcpServer.OnAccept事件。 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. 使用该客户端的所有套接字必须在TTcpServer.OnAccept事件的上下文中完成,使用事件提供的TCustomIpClient对象的方法。 As soon as the event handler exits, TTcpServer closes the connection. 一旦事件处理程序退出, TTcpServer就会关闭连接。 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. 如果TTcpServer.BlockMode属性设置为bmThreadBlocking ,则OnAccept事件处理程序在由TTcpServer管理的线程中运行,因此您无需创建自己的线程。 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. 否则,您需要在自己的代码中调用TTcpServer.Accept()方法,在这种情况下,如果需要,您可以在自己的线程中调用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM