Unsolved QNetworkAccessManager advice
-
I'm looking to wrap some code I've got up into a utility library for others to use (and make it 'source available') - and some of my code uses a singleton wrapped QNetworkAccessManager object - but only connects to signals on the network reply objects.
If someone uses this utility library and their code has their own QNetworkAccessManager which they rely on for separate uses - is there any way to protect the sanctity of my code's QNetworkAccessManager?) Is that even necessary any more?
I seem to recall that pre-Qt5 there was at least some global state associated with a QNetworkAccessManager object and having more than one was problematic. I may be misremembering.
Looking for advice from those who have used it in similar fashion - thanks :)
-
Hi,
AFAIR, there's no problem using several QNetworkAccessManager objects. Just remember that you can't have more than 6 concurrent requests. After that the following are queued.
-
@SGaist - per process or per QNetworkAccessManager?
If it's per process, that suggests an underlying singleton (in pattern, not object necessarily.)
This would be worrying because it means that it's possible the client and the SDK are contending for the same 6 request resources across the entire process.
Or - is the 6 connection limit a limit on connections to the same host? If so, then that's no worry at all.
Thanks @SGaist - you make life much easier for all of us :) (Seriously - just knowing you're around is like a warm blanket of 'dude, chill')
-
@SGaist Looking at qtbase/src/network/access/qhttpnetworkconnection.cpp suggests that it is 6 connections, irrespective of destination, per network access manager.
That would be great, as I can't step on the client (unless I do something really dumb) and the client can't step on me - they can (only in some expectedly rare cases) affect my network code's performance.
-
Yes, it's per QNAM object.