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. How to upgrade existing HTTP socket created by QNAM to Websocket
Qt 6.11 is out! See what's new in the release blog

How to upgrade existing HTTP socket created by QNAM to Websocket

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 966 Views
  • 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.
  • K Offline
    K Offline
    KaCMaHaBT
    wrote on last edited by
    #1

    Hi,

    I doing a HTTP request via QNetworkAccessManager. I set a 'Keep-Alive' option, and hope a socket will not be closed. Next I create QWebSocket to the same address and port.
    Problem is the QWebSocket uses a new source port, but I want to reuse old one, the port from the QNAM.

    How I can reuse the old source port in QWebSocket?

    aha_1980A 1 Reply Last reply
    0
    • K KaCMaHaBT

      Hi,

      I doing a HTTP request via QNetworkAccessManager. I set a 'Keep-Alive' option, and hope a socket will not be closed. Next I create QWebSocket to the same address and port.
      Problem is the QWebSocket uses a new source port, but I want to reuse old one, the port from the QNAM.

      How I can reuse the old source port in QWebSocket?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @KaCMaHaBT Hi, Qt 5.9 introduced handleConnection exactly for this usecase.

      Qt has to stay free or it will die.

      K 1 Reply Last reply
      2
      • aha_1980A aha_1980

        @KaCMaHaBT Hi, Qt 5.9 introduced handleConnection exactly for this usecase.

        K Offline
        K Offline
        KaCMaHaBT
        wrote on last edited by
        #3

        @aha_1980 Thank you!

        1 Reply Last reply
        1
        • K Offline
          K Offline
          KaCMaHaBT
          wrote on last edited by
          #4

          Hi.
          I thanked too early :)
          First of all -- this is websocketserver, but I trying to make a websocket client, like a browser.
          Second thing -- we don't have an access to the socket in QNAM and cannot create a custom socket for connection like in early versions of Qt. QHTTP and theirs method setSocket are marked as deprecated.
          So, the problem still the actual

          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