Problem with QTcpSocket and javascript client
-
Use QWebSocket: https://doc.qt.io/qt-5/echoclient.html
-
Use QWebSocket: https://doc.qt.io/qt-5/echoclient.html
@eyllanesc Hi thanks for your reply. I tried to include websocket in .pro but when u compile always say include qwebsocket bit found
-
Use QWebSocket: https://doc.qt.io/qt-5/echoclient.html
@eyllanesc said in Problem with QTcpSocket and javascript client:
Use QWebSocket: https://doc.qt.io/qt-5/echoclient.
I guess the OP needs to use WebSockets on the server side. Please see this example.
-
Previous replies are not correct. OP is trying to use a QTcpServer with javascript client, so he's actually working on the server side. The correct Qt class for that is QWebSocketServer. The page also has examples, so should be straightforward.
-
Previous replies are not correct. OP is trying to use a QTcpServer with javascript client, so he's actually working on the server side. The correct Qt class for that is QWebSocketServer. The page also has examples, so should be straightforward.
-
@Taytoo So i nedd to use QWebsocket, but how can I include the .h file? As i said I put in .pro qwebsocket but the compiler cant found qwebsocket header file. Im new in qt, I suppose something its needed install?
@Mhamon said in Problem with QTcpSocket and javascript client:
As i said I put in .pro qwebsocket
It's
QT += websocketsas shown here https://doc.qt.io/qt-5/qwebsocket.html
-
Previous replies are not correct. OP is trying to use a QTcpServer with javascript client, so he's actually working on the server side. The correct Qt class for that is QWebSocketServer. The page also has examples, so should be straightforward.
@Taytoo said in Problem with QTcpSocket and javascript client:
Previous replies are not correct.
With due respect, I do consider my reply correct since I pointed the OP to the Websokects echo server example, which according to its description:
The Echo Server Example shows how to create a simple server application that sends back the messages it receives, using the WebSocket API.
and looking at its source code, you can see clearly that it uses a QWebSocketServer
EchoServer::EchoServer(quint16 port, bool debug, QObject *parent) : QObject(parent), m_pWebSocketServer(new QWebSocketServer(QStringLiteral("Echo Server"), QWebSocketServer::NonSecureMode, this)),and the .pro clearly shows how to reference the Qt Websockets module:
QT = websockets TARGET = echoserver CONFIG += console ... -
@Taytoo said in Problem with QTcpSocket and javascript client:
Previous replies are not correct.
With due respect, I do consider my reply correct since I pointed the OP to the Websokects echo server example, which according to its description:
The Echo Server Example shows how to create a simple server application that sends back the messages it receives, using the WebSocket API.
and looking at its source code, you can see clearly that it uses a QWebSocketServer
EchoServer::EchoServer(quint16 port, bool debug, QObject *parent) : QObject(parent), m_pWebSocketServer(new QWebSocketServer(QStringLiteral("Echo Server"), QWebSocketServer::NonSecureMode, this)),and the .pro clearly shows how to reference the Qt Websockets module:
QT = websockets TARGET = echoserver CONFIG += console ...@Pablo-J-Rogina yes as I said in .pro added websockets BUT can't include in project, always show error QT= websockets file not foud. Here the problem id not the use it the example, I think its the configuration.
Here show:


"Project ERROR: Unknown module(s) in QT: websockets"