I want to reduce data rate(Bandwidth throttling) for my mac os x application.
I already try place sleep in - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
method but it does not help me.
I am also check this question
Limit NSURLConnection data rate? (Bandwidth throttling)
but this will not helps me.
Is there is other way to achieve Bandwidth throttling in objective c
-
i have the same problem in my app , please share any one ans for this question – Vaibhav Shiledar Sep 14 '16 at 08:08
1 Answers
The problem is that the work is happening on a different thread.
If you really need to do bandwidth throttling, there's pretty much only one way to do it, and that is to manage the socket connection yourself. That basically means either writing your own HTTP request classes or using libcurl.
And be aware that if you go down that path, if you ever need to do this on iOS, you would also need to at least occasionally make short high-level requests with NSURLConnection or NSURLSession to keep the cellular radio awake.
You might also be able to do throttling by embedding an HTTP proxy library in your app, using NSURLSession instead of NSURLConnection, and configuring it to send all requests through that proxy, then modifying the proxy code to limit the speed at which it reads data from the socket.
None of these approaches are for the faint of heart.
Or if you don't care whether the app itself does the throttling, there are a number of bandwidth shaping tools that you might consider (e.g. network link conditioner).

- 10,129
- 1
- 28
- 49