简单的 WebSocket 聊天程序
一个使用 WebSocket 协议的简易聊天应用程序。
本应用演示了如何使用QWebSocket 和QWebSocketServer 类,基于WebSocket协议构建一个极简聊天应用。该示例是一个服务器,允许多个客户端连接至其上以发送和接收消息。
默认情况下,它监听 localhost 的 1234 端口。它会记录所有已连接的客户端,每当有客户端向服务器发送消息时,该消息就会转发给所有其他客户端。当客户端断开连接时,它将从客户端列表中移除。

此外,还提供了一个 HTML 客户端,用于连接和断开与服务器的连接、查询连接状态、发送消息以及查看其他客户端发送的所有消息。
© 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.