I'm writing an app in C# that downloads concurrently (in different threads) using multiple connections to multiple servers, and I'd like to be able to limit the used bandwidth.
For a single connection the solution would be simple; I'd use the solution posted here : http://www.codeproject.com/KB/IP/Bandwidth_throttling.aspx which calculates a sleep-time for the single connection.
I'd like to know what the best way is to do this for multiple connections.
Using the ThrottledStream posted above and dividing the bandwidth (say 2MB/sec) evenly among the connections isn't right, if I'd have 3 very slow connections and 1 very fast one they'd all be capped to 512kb/sec, so the fast one won't go above 512kb/sec and the other 3 wouldn't even make that.
The preferred solution I think is to cap only the fastest connection(s) so the slower connections are used optimally.
Does anyone have any experience with this, example code or any advice ?