WebSocket Echo 客户端
演示如何编写一个简单的 WebSocket 客户端程序。
Echo Client 演示了如何使用WebSocketAPI 向服务器发送消息,并处理服务器返回的任何响应--在本例中,只需报告响应即可。
默认情况下,客户端会打开一个 WebSocket 连接,连接到监听本地端口 1234 的服务器。连接尝试成功后,客户端将向服务器发送一条信息,并打印出服务器发送的任何响应。然后,客户端关闭连接。
为便于说明,我们使用WebSocket Echo 服务器,其回复只是发送的消息。
另请参阅 WebSocket Echo Server。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.