WebSocket 回显服务器

演示如何编写一个简单的 WebSocket 服务器应用程序。

本回显服务器演示了如何使用WebSocketAPI 创建一个简单的服务器应用程序,该应用程序会在收到消息后发送回一条响应。为便于说明,该响应仅是消息的副本。

如果您的网页浏览器支持WebSocket,您还可以使用它打开echoserver/echoclient.html{echoclient.html} 文件,并按照下图所示进行操作:

WebSocket 回显 HTML 客户端

否则,请使用WebSocket Echo Client连接到服务器。

示例项目 @ code.qt.io

另请参阅 WebSocket 回显客户端。

© 2026 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.