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 do I make a network request in Qt binding to a specific interface/IP?
QtWS25 Last Chance

How do I make a network request in Qt binding to a specific interface/IP?

Scheduled Pinned Locked Moved Solved General and Desktop
qnetworkrequestqnetworkaccessmqnamhttppost
7 Posts 5 Posters 1.1k 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.
  • A Offline
    A Offline
    Abb Per
    wrote on last edited by Abb Per
    #1

    So as of Qt 5, QHttp is deprecated and we're all supposed to use QNetworkAccessManager now. Fine. But how do I make a post request (HTTP) from my multihomed ( linux machine with 2 ethernet network or/and windows machine with one ethernet interface with 10 different ip <192.168.4.12 106.45.32.12 19.5.11.12 vs>) machine without feeling like I'm playing roulette?

    I need to be able to specify the source address to be used in post request.

    If there is no way, then what is a workaround? For my specific case right now, I just need to post request with HTTP. But is there really no way to do this in a generic way with QtNetworkAccessManager?

    JonBJ raven-worxR artwawA 3 Replies Last reply
    0
    • A Abb Per

      So as of Qt 5, QHttp is deprecated and we're all supposed to use QNetworkAccessManager now. Fine. But how do I make a post request (HTTP) from my multihomed ( linux machine with 2 ethernet network or/and windows machine with one ethernet interface with 10 different ip <192.168.4.12 106.45.32.12 19.5.11.12 vs>) machine without feeling like I'm playing roulette?

      I need to be able to specify the source address to be used in post request.

      If there is no way, then what is a workaround? For my specific case right now, I just need to post request with HTTP. But is there really no way to do this in a generic way with QtNetworkAccessManager?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Abbas-Percin
      I'm interested: was it you who asked this question over 7 years ago, or did you just copy it verbatim for some reason? You just keep popping up asking the same question when you've seen nobody can answer it to your satisfaction :)

      A 1 Reply Last reply
      2
      • A Abb Per

        So as of Qt 5, QHttp is deprecated and we're all supposed to use QNetworkAccessManager now. Fine. But how do I make a post request (HTTP) from my multihomed ( linux machine with 2 ethernet network or/and windows machine with one ethernet interface with 10 different ip <192.168.4.12 106.45.32.12 19.5.11.12 vs>) machine without feeling like I'm playing roulette?

        I need to be able to specify the source address to be used in post request.

        If there is no way, then what is a workaround? For my specific case right now, I just need to post request with HTTP. But is there really no way to do this in a generic way with QtNetworkAccessManager?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @Abbas-Percin said in How do I make a network request in Qt binding to a specific interface/IP?:

        I need to be able to specify the source address to be used in post request.

        the interface for outgoing data is usually chosen by the OS

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        3
        • A Abb Per

          So as of Qt 5, QHttp is deprecated and we're all supposed to use QNetworkAccessManager now. Fine. But how do I make a post request (HTTP) from my multihomed ( linux machine with 2 ethernet network or/and windows machine with one ethernet interface with 10 different ip <192.168.4.12 106.45.32.12 19.5.11.12 vs>) machine without feeling like I'm playing roulette?

          I need to be able to specify the source address to be used in post request.

          If there is no way, then what is a workaround? For my specific case right now, I just need to post request with HTTP. But is there really no way to do this in a generic way with QtNetworkAccessManager?

          artwawA Offline
          artwawA Offline
          artwaw
          wrote on last edited by
          #4

          @Abbas-Percin To add to @raven-worx - in presence of multiple network interfaces OS determines the routes. If queried address spaces is not directly attached routing protocols are used to determine the route, usually in the least-effort mode.

          For more information please re-read.

          Kind Regards,
          Artur

          1 Reply Last reply
          1
          • JonBJ JonB

            @Abbas-Percin
            I'm interested: was it you who asked this question over 7 years ago, or did you just copy it verbatim for some reason? You just keep popping up asking the same question when you've seen nobody can answer it to your satisfaction :)

            A Offline
            A Offline
            Abb Per
            wrote on last edited by
            #5

            @JonB said in How do I make a network request in Qt binding to a specific interface/IP?:

            I'm sorry if I sound like I'm spamming. But many people have this problem. So I'm asking you please not to think that we are all the same individual.
            I just mentioned this issue at https://forum.qt.io/topic/127720/host-source-not-destination-adress-in-networkaccessmanager-post-function 3 week ago.

            But I didn't like the language of the paragraph I wrote afterwards. So I rewrote it now in a simpler and cleaner way.

            Probably even there is solution it wont work for me because it's too late for the project I'm working on. But for those who are in the same situation, at least it will help.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Abb Per
              wrote on last edited by
              #6

              @raven-worx @artwaw As a result of my research, I came to this truth too. Still, I wanted to get answers from the authorities before finalizing my research completely. Thank you very much for your answers.
              Best regards
              Abbas Perçin

              1 Reply Last reply
              0
              • Guy GizmoG Offline
                Guy GizmoG Offline
                Guy Gizmo
                wrote on last edited by
                #7

                Forgive me for bumping an old thread, but I too am interested in an answer to this question. As things stand I'm going to commit to using out-of-date APIs in order to accomplish this. But it'd be nice if there were an officially supported and modern way to make socket connections and HTTP / HTTPS requests using a specific network interface.

                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