My application lets the user choose a domain from a source list to fetch a bunch of subpages (using HttpURLConnection). To the user this looks like a single, large download. Multiple downloads may be running at once and I need to report their individual transfer rates to the gui. I attempted to create a
TransferMonitor, but it isn't working as expected (thanks to ejp for your attempts to help out).
My second thought is to let an external library handle the actual monitoring. I think either
jpcap, [sourceforge jpcap|http://jpcap.sourceforge.net/] or
jnetpcap could do this. The idea is that I can use this library to get the download rate for the jvm process. If I keep track of the bytes downloaded by each thread per second I can compute a ratio and use this in combination with the download rate for the entire process to compute individual transfer rates for each thread.
However, I cannot find an example on how to monitor the download rate of a process using any of these libraries (or any other if such exists). Could someone that has done this before, or has a much better understanding of how this works, please post a sample on how I can accomplish this?