Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QTcpSocket and javascript client
Qt 6.11 is out! See what's new in the release blog

Problem with QTcpSocket and javascript client

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 5 Posters 997 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • eyllanescE Offline
    eyllanescE Offline
    eyllanesc
    wrote on last edited by
    #2

    Use QWebSocket: https://doc.qt.io/qt-5/echoclient.html

    If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

    M Pablo J. RoginaP 2 Replies Last reply
    1
    • eyllanescE eyllanesc

      Use QWebSocket: https://doc.qt.io/qt-5/echoclient.html

      M Offline
      M Offline
      Mhamon
      wrote on last edited by
      #3

      @eyllanesc Hi thanks for your reply. I tried to include websocket in .pro but when u compile always say include qwebsocket bit found

      1 Reply Last reply
      0
      • eyllanescE eyllanesc

        Use QWebSocket: https://doc.qt.io/qt-5/echoclient.html

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #4

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

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1
        • T Offline
          T Offline
          Taytoo
          wrote on last edited by
          #5

          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.

          M Pablo J. RoginaP 2 Replies Last reply
          0
          • T Taytoo

            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.

            M Offline
            M Offline
            Mhamon
            wrote on last edited by
            #6

            @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?

            jsulmJ 1 Reply Last reply
            0
            • M Mhamon

              @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?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @Mhamon said in Problem with QTcpSocket and javascript client:

              As i said I put in .pro qwebsocket

              It's

              QT += websockets
              

              as shown here https://doc.qt.io/qt-5/qwebsocket.html

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • T Taytoo

                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.

                Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by Pablo J. Rogina
                #8

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

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                M 1 Reply Last reply
                0
                • Pablo J. RoginaP Pablo J. Rogina

                  @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
                  ...
                  
                  M Offline
                  M Offline
                  Mhamon
                  wrote on last edited by Mhamon
                  #9

                  @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:
                  alt text

                  alt text

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

                  1 Reply Last reply
                  0
                  • eyllanescE Offline
                    eyllanescE Offline
                    eyllanesc
                    wrote on last edited by
                    #10

                    @Mhamon 1) what is your Qt version ? 2) How have you installed Qt? 3) what is your OS?

                    If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Mhamon
                      wrote on last edited by
                      #11

                      Thanks to all.
                      Solved - reinstalled qt and work fine.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved