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. Bind QWebSocket & QNetworkAccessManager to specific local Interface/IP?
Servers for Qt installer are currently down

Bind QWebSocket & QNetworkAccessManager to specific local Interface/IP?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.1k 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.
  • T Offline
    T Offline
    Taytoo
    wrote on 28 Aug 2019, 12:19 last edited by Taytoo
    #1

    Is there any way to bind QWebsocket & QNetworkAccessManager to a specific local IP?

    For QWebSocket, the only option I see is an undocumented constructor for QWebSocket which takes pQTcpSocket.

    QWebSocket(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version, QObject *pParent);
    

    One could theoretically create a QTcpSocket, bind it to specific IP and then pass it to websocket constructor. Would that work? Any possible issues with this?

    Couldn't find any possible way of doing the same for QNetworkAccessManager. Any ideas?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Taytoo
      wrote on 28 Aug 2019, 13:27 last edited by
      #2

      Update: Tried passing QTcpSocket to QWebSocket constructor but compiler is giving "cannot access private member" error.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 28 Aug 2019, 15:51 last edited by
        #3

        What's wrong with QWebSocketServer::listen()?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        T 1 Reply Last reply 29 Aug 2019, 06:01
        1
        • C Christian Ehrlicher
          28 Aug 2019, 15:51

          What's wrong with QWebSocketServer::listen()?

          T Offline
          T Offline
          Taytoo
          wrote on 29 Aug 2019, 06:01 last edited by
          #4

          @christian-ehrlicher Its a client websocket. I want to bind client socket to a specific local interface/IP e.g. if a computer has two network cards, wifi and ethernet, and user wants software(websocket) to use ethernet interface for all communications.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 29 Aug 2019, 06:07 last edited by
            #5

            This is currently not supported with QWebSocket

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            T 1 Reply Last reply 29 Aug 2019, 06:27
            0
            • C Christian Ehrlicher
              29 Aug 2019, 06:07

              This is currently not supported with QWebSocket

              T Offline
              T Offline
              Taytoo
              wrote on 29 Aug 2019, 06:27 last edited by Taytoo
              #6

              @christian-ehrlicher I'm building static Qt myself. If I just add a bind method to QWebSocket and forward that call to internal pTcpSocket, would that be ok?

              Can I submit this change for inclusion into Qt code?

              A 1 Reply Last reply 29 Aug 2019, 11:20
              1
              • T Taytoo
                29 Aug 2019, 06:27

                @christian-ehrlicher I'm building static Qt myself. If I just add a bind method to QWebSocket and forward that call to internal pTcpSocket, would that be ok?

                Can I submit this change for inclusion into Qt code?

                A Offline
                A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on 29 Aug 2019, 11:20 last edited by
                #7

                @taytoo said in Bind QWebSocket & QNetworkAccessManager to specific local Interface/IP?:

                @christian-ehrlicher I'm building static Qt myself. If I just add a bind method to QWebSocket and forward that call to internal pTcpSocket, would that be ok?

                Can I submit this change for inclusion into Qt code?

                I'm not the maintainter of QWebSocket, but I think the answer to both questions is yes.

                Have a look at https://wiki.qt.io/Qt_Contribution_Guidelines to get started with your contribution.

                Regards

                Qt has to stay free or it will die.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 29 Aug 2019, 18:24 last edited by
                  #8

                  I would add something like QWebSocket::setBindAddress(const QHostAddress &address, quint16 port = 0, QAbstractSocket::BindMode mode = DefaultForPlatform) which could then be used in QWebSocketPrivate::open()

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  1

                  1/8

                  28 Aug 2019, 12:19

                  • Login

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