On Nov 19, 2009, at 7:51 PM, Jens Alfke wrote:

> On Nov 19, 2009, at 3:40 PM, Colin Deasy wrote:
> 
>> This shared thread is actually handling potentially large numbers of 
>> concurrent url connections/downloads. The reason that I want a block in some 
>> of those at different times is a for a form of bandwidth control I am trying 
>> to do.
> 
> I don't think that will do what you want. The actual socket I/O happens in a 
> background thread owned by CFNetwork; I don't think that thread will stop 
> reading data just because your callback on the main thread hasn't returned 
> yet. It just means that, when you do return, you'll immediately get a bigger 
> chunk of data.
> 
> I've seen this general question of rate limiting asked on the macnetworkprog 
> list. IIRC the answer is that Foundation and CFNetwork don't really give you 
> the tools to do it. You'd have to write your own code using low-level BSD 
> sockets APIs. :-P

You can actually do this using CFNetwork. If you schedule your read stream on a 
runloop and read the bytes you want in the appropriate callback (one of type 
CFReadStreamClientCallBack) with CFReadStreamRead, you can successfully control 
the bandwidth by limiting the number of calls to CFReadStreamRead.

Hank

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to