PDA

View Full Version : Network statistics with QNetworkAccessManager



The_Fallen
20th September 2010, 00:19
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

wysota
20th September 2010, 00:29
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.

The_Fallen
20th September 2010, 01:02
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.

wysota
20th September 2010, 01:09
You are not supposed to use any proxy classes. You are to implement a network proxy (i.e. a SOCKS5 proxy).

The_Fallen
20th September 2010, 01:38
Yes, sure, but how?

wysota
20th September 2010, 01:41
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 ;)

The_Fallen
20th September 2010, 01:46
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...

wysota
20th September 2010, 02:01
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.


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.