开发者

NetworkStream.Read download progress. In similar to WebClient.DownloadProgressChanged

开发者 https://www.devze.com 2023-02-07 10:02 出处:网络
I want to know current download progress when im using NetworkStream.Read. Is it even p开发者_Go百科ossible? Do i have to use webclient?

I want to know current download progress when im using NetworkStream.Read. Is it even p开发者_Go百科ossible? Do i have to use webclient?

I dont want to use webclient because it seems(im not 100% sure)

  1. i have to create webserver
  2. i have to create file (instead of memory stream data).
  3. i cannot properly measure transfer speed of gigabit networks, due to http protocol limitation.

or, i should use webclient?

FYI, Im building bandwidth estimation tools.


What's the problem?

  1. Get the current time
  2. Invoke ´stream.Read(buffer, 0, buffer.Length);` in a loop until you get enough bytes to calculate a proper rate
  3. Take end time
  4. Divide the received byte length with number of seconds it took download them.
  5. Result = bytes/s
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号