Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QWebSocketServer moving new connections to a own thread

    General and Desktop
    4
    7
    2531
    Loading More Posts
    • 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.
    • M
      M4chin3 last edited by

      Hi,

      I'm developing a client-server application. Therefore I'm using the QWebSocket class to achieve binary transparency for the sent messages. To listen for incoming connections I'm using the QWebSocketServer class which works pretty nice so far. (basically the echoclient and echoserver example)

      Now my question:
      I would like to have a thread for every incoming connection (the QTcpServer class does support this) but the documentation says the returned QWebSocket* pointer by nextPendingConnection() cannot be used from another thead. Is this somehow possible and how?

      1 Reply Last reply Reply Quote 1
      • mrdebug
        mrdebug last edited by

        @void QCNetHTTPServer::incomingConnection(int socketDescriptor) {
        QThNetHTTPServerConn *ThNetHTTPServerConn= new QThNetHTTPServerConn(this, socketDescriptor);
        ThNetHTTPServerConn->start();

        ....

        void QThNetHTTPServerConn::run() {
        QTcpSocket *QTSClient= new QTcpSocket();
        QTSClient->setSocketDescriptor(socketDescriptor);
        @

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        1 Reply Last reply Reply Quote 0
        • M
          M4chin3 last edited by

          Correct for the QTcpSocket and QTcpSocketServer classes.
          But I'm asking for the QWebSocket and QWebSocketServer classes.

          QWebSocketServer does not have the method incomingConnection. So I can't overwrite it, or am I seeing this wrong?

          Any further ideas?

          1 Reply Last reply Reply Quote 0
          • mrdebug
            mrdebug last edited by

            Really I didn't know that QWebSocket existed and I don't know what QWebSocket can do.
            For my own programs that need to exchange data over network, I normally use a custom http server and client components.
            The server component uses QThread and is written on pure Qt code. I can use it for a normal http server activity and for mpeg tunnel.
            Is not so hard to write.

            What do you have to do exactly?

            Need programmers to hire?
            www.labcsp.com
            www.denisgottardello.it
            GMT+1
            Skype: mrdebug

            1 Reply Last reply Reply Quote 0
            • M
              M4chin3 last edited by

              Websockets provide the features I need without further implementation:

              • binary transparent data transfer
              • bidirectional
              • TCP based

              HTTP is missing the bidirectional feature.
              TCP is missing the binary transparent data transfer feature.

              Therefore I want to use Websockets instead of implementing custom components to TCP sockets or HTTP transfer classes.

              1 Reply Last reply Reply Quote 0
              • Xandl
                Xandl last edited by

                Bump for interest.
                QWebsocket actually has a private constructor where it accepts an QTcpSocket pointer - but sadly, it's private.

                JKSH 1 Reply Last reply Reply Quote 0
                • JKSH
                  JKSH Moderators @Xandl last edited by

                  @Xandl said:

                  Bump for interest.
                  QWebsocket actually has a private constructor where it accepts an QTcpSocket pointer - but sadly, it's private.

                  If you believe this is a feature that should be made public, submit a request to https://bugreports.qt.io/

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post