QWebSocket Class

Implements a TCP socket that talks the WebSocket protocol. More...

Header: #include <QWebSocket>
qmake: QT += websockets
Since: Qt 5.3
Inherits: QObject

This class was introduced in Qt 5.3.

Detailed Description

WebSockets is a web technology providing full-duplex communications channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011. QWebSocket can both be used in a client application and server application.

This class was modeled after QAbstractSocket.

QWebSocket currently does not support WebSocket Extensions and WebSocket Subprotocols.

QWebSocket only supports version 13 of the WebSocket protocol, as outlined in RFC 6455.

Note: Some proxies do not understand certain HTTP headers used during a WebSocket handshake. In that case, non-secure WebSocket connections fail. The best way to mitigate against this problem is to use WebSocket over a secure connection.

Warning: To generate masks, this implementation of WebSockets uses the reasonably secure QRandomGenerator::global()->generate() function. For more information about the importance of good masking, see "Talking to Yourself for Fun and Profit" by Lin-Shung Huang et al. The best measure against attacks mentioned in the document above, is to use QWebSocket over a secure connection (wss://). In general, always be careful to not have 3rd party script access to a QWebSocket in your application.

See also QAbstractSocket, QTcpSocket, and QWebSocket client example.