RE: NSRunloop + shared thread
RE: NSRunloop + shared thread
- Subject: RE: NSRunloop + shared thread
- From: Colin Deasy <email@hidden>
- Date: Sat, 21 Nov 2009 16:39:45 +0000
- Importance: Normal
Hey,
Thanks for the info. I'll certainly look into the CFNetwork API. I was really hoping for a nice solution to come about for the cocoa API's but I've since given up hope and started using libcurl, which is actually a really nice library to work with.
Thanks for all the help
> Subject: Re: NSRunloop + shared thread
> From: email@hidden
> Date: Fri, 20 Nov 2009 09:28:02 -0500
> CC: email@hidden; email@hidden
> To: email@hidden
>
> 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
>
_________________________________________________________________
Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden