On Sun, 13 Jun 2010, Patrick K. wrote:

I don't need a very high precision but I need a value that looks alright. Imagine I'm downloading a file at 1600kb/s which in this case is the maximum for the used connection. Now I'm starting another download. What happens is that the speed is divided to both downloads.

... and now you're complicating things without telling us which way you prefer. "Download speed" could mean all downloads taken together, or does it refer to just one of them?

I should mention that I asked for the average speed before the download was finished. (Is this legal or doesn't it work for a not finished download?)

curl_easy_getinfo() is documented and I quote from the man page:

  "Use this function AFTER a performed transfer if you want to get transfer-
  oriented data."

So no, you can't use this to get info updated while the transfer is in progress.

But maybe I'm just doing something else wrong. Lets assume this is how my callback looks like (I'm using C++ Classes so the static is needed): static int callback(char *data, unsigned int size, unsigned int nmemb, void *ptr);

So the total size of data that had been received is (size * nmemb).

Not at all. Again, this is documented. size * nmemb is the total size of data you receive in that particular function call. That function is called many times to end up a complete file.

So inside the function I'm checking how much time passed.

That you can do, but you need to add up the total amount of data to make it right. Or use the progress callback that includes the total size among its arguments.

--

 / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to