I'm trying to upload files to a server but I would like to limit the maximum upload speed that it sends the files at. the reasoning is some people who will use this program have awful upload speeds and when uploading the files, it really lags them. so i would like to limit the maximum upload speed if at all possible. here is the code that is currently doing the uploading. yes i know it is very basic, its more dynamic in the code but this is the basics of it. if anyone could point me in the right direction, i would greatly appreciate it.
WebClient myWebClient = new WebClient();
myWebClient.UploadFile(""http://myurl", "POST", "C:\\windows\\test.jpg");
well i dont want to delay it because i would still encounter the same problem. every time it uploaded a chunk, it would do it at max speed it possibly could. i dont want that. i want to completely throttle it down to do like 5KB/s maximum. if i just sleep it, i will still get lag spikes and i cant have that.
In its simplest sense all throttling is really doing is sending X number of bytes at a time then waiting X amount of time to ask for more data. This can be achieved by overloading the stream class, however, you may have to use something other than a WebClient to achieve throttling.
yeah i stumbled upon that earlier today and im probably going to end up going that way. but the problem is what im sending it to. im sending it to a php page and specifying variables in the url for php to use. cause i need to specify which person the file is from and where the destination on the server is. so with that, i'm totally clueless as to how to use this method to do it because that would require me to use sockets, which would make it hard to specify any extra info other than just the file. mainly because i dont know *** i'm doing with php. and i cant develop a c# server for this either because the server is on a linux box.
Well you can probably use HttpWebRequest to transfer what you need to or you can use sockets to send it. I remember awhile back I had to use sockets to post something with PHP all you need to do is construct the header correctly and its really just as simple as sending a stream of bytes through the socket to the right url / port.
Not sure if it helps but here was the php code i used maybe you can convert it to C#