安全 WebSocket Echo 服务器

通过安全 WebSocket (wss) 回应客户端的简单服务器。

Secure WebSocket Echo Server 示例展示了如何使用QWebSocketServer 类通过安全套接字(wss)实现简单的回声服务器。本示例需要 TLS 支持才能运行。它向客户端进行身份验证,成功后可接受来自客户端的消息并作出响应。为了便于说明,它的响应只是发送的信息的副本。

该服务器配置了自签名证书和密钥。除非联系该服务器的客户端被配置为信任该证书(安全 WebSocket Echo Client就是这样配置的),否则它们将拒绝该服务器。

安全 WebSocket Echo HTML 客户端

本例中还有一个基于 HTML 的客户端。但它只有在所使用的浏览器支持上述证书,或忽略本地主机地址的 TLS 错误时才能工作。

示例项目 @ code.qt.io

另请参阅 安全 WebSocket Echo 客户端WebSocket Echo 服务器

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