Re: Limit data rate with an NSURLConnection
Re: Limit data rate with an NSURLConnection
- Subject: Re: Limit data rate with an NSURLConnection
- From: "Craig A. Haney" <email@hidden>
- Date: Wed, 1 Jun 2005 21:36:16 -0400
Title: Re: Limit data rate with an
NSURLConnection
Have you read up on IPFW (man ipfw) with traffic shaping?
-craig
At 21:16 -0400 06/01/2005, Michael Rothwell wrote:
In answer to my own connection,
"Yes, there is!"
I made a wrapper class for
NSURLConnection (et al) that starts a runloop and sets up
NSURLConnection in a worker thread. In each didReceiveData: callback,
I usleep(25000), which limits the rate at which data can be read from
the remote device. I also buffer up the received data and call the
client on the main thread only when "maxBufferSize" bytes
have accumulated, or one second has passed and there is data,
whichever comes first. This effectively rate-limits my connection
speed, and lowers my program's CPU usage because I'm calling its
data-processing methods less frequently and with more data each time.
I avoid starvation on already-slow connections by using the one-second
timer.
-M
On May 30, 2005, at 10:04 PM, Michael
Rothwell wrote:
Hello,
Is there a way to limit the data rate for
an NSURLConnection? Let's say
that I don't wish for a particular request to consume more than 1 mbit
of network bandwidth. How might that be accomplished?
_______________________________________________
Do not post admin requests to the list.
They will be ignored.
Cocoa-dev mailing
list (email@hidden)
Help/Unsubscribe/Update your
Subscription:
us
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden