How do I make a network request in Qt binding to a specific interface/IP?
-
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?
-
@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 :) -
@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
-
@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.
-
@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.
-
@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 -
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.