Network statistics with QNetworkAccessManager
Hey,
is there a way to obtain the total number of bytes sent/received from a QNetworkAccessManager object? Or do I need to keep track of all requests/replies to do that? But even then I'm missing all the overhead and only get the size of the plain data sent/received, am I not?
Any ideas how to do that? Thanks.
Cheers,
fallen
Re: Network statistics with QNetworkAccessManager
The class doesn't hold any statistics. Even if you track all the requests and replies manually, you won't get the total size transmitted/received, at least not for ssl connections (you won't have access to the encrypted stream). If you need such data, implement your own network proxy and setup the network access manager to forward all connections though it. Then you'll be able to track each byte that flows through it.
Re: Network statistics with QNetworkAccessManager
Quote:
Originally Posted by
wysota
The class doesn't hold any statistics. Even if you track all the requests and replies manually, you won't get the total size transmitted/received, at least not for ssl connections (you won't have access to the encrypted stream). If you need such data, implement your own network proxy and setup the network access manager to forward all connections though it. Then you'll be able to track each byte that flows through it.
Thanks, but after digging through the documentation available for the proxy classes and their sources, I can't really figure out how to use them in order to count the bytes flowing through. I can't even find any methods that allow any bytes to flow through... Any further help would be very appreciated.
Re: Network statistics with QNetworkAccessManager
You are not supposed to use any proxy classes. You are to implement a network proxy (i.e. a SOCKS5 proxy).
Re: Network statistics with QNetworkAccessManager
Re: Network statistics with QNetworkAccessManager
Quote:
Originally Posted by
The_Fallen
Yes, sure, but how?
Khem... First write the code, then compile it and then test it :cool:
And seriously it would be a good idea to read a bit about how network proxies work ;)
Re: Network statistics with QNetworkAccessManager
Phantastic answer... What do you think, why I'm asking? Can't find anything more specific about network proxies in Qt. Or are you seriously suggesting to write a stand-alone proxy server to handle this task and then connect to it from my Qt app? Great idea...
Re: Network statistics with QNetworkAccessManager
Quote:
Originally Posted by
The_Fallen
Can't find anything more specific about network proxies in Qt.
Who said anything about Qt? I said you should implement the proxy, not use it so why are you searching in Qt for it? It's not there.
It's really not that compilcated to enter "SOCKS5" (or SOCKS4 or simply SOCKS) in your favourite web search engine and see what pops up.
Quote:
Or are you seriously suggesting to write a stand-alone proxy server to handle this task and then connect to it from my Qt app?
No, not a stand alone server. Just a little class which will receive connections from the network access manager, serve as a socket server for it and do the bookkeeping in-between.