WebSocket 迴顯客戶端

展示如何編寫簡單 WebSocket 客戶端應用程序。

迴顯客戶端展示如何使用 WebSocket API to send a message to a server and process whatever response the server returns - in this case, simply reporting the response.

The client by default opens a WebSocket connection to a server listening on local port 1234. When the connection attempt is successful, the client will send a message to the server and print out whatever response the server sends. The client then closes the connection.

WebSocket Echo Console Client

For the sake of illustration, we use the WebSocket 迴顯服務器 , whose reply is simply the message that was sent.

範例工程 @ code.qt.io

另請參閱 WebSocket 迴顯服務器 .