• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Limit data rate with an NSURLConnection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Limit data rate with an NSURLConnection (From: Michael Rothwell <email@hidden>)

  • Prev by Date: Re: NSTableView drawing a background image...(answer my own question)
  • Next by Date: Re: [SOLVED] NSString's drawInRect: problems
  • Previous by thread: Re: Limit data rate with an NSURLConnection
  • Next by thread: Setting the "Open with" attribute on a file
  • Index(es):
    • Date
    • Thread