Re: Does CFSocket use efficient polling?
Re: Does CFSocket use efficient polling?
- Subject: Re: Does CFSocket use efficient polling?
- From: Eli Bach <email@hidden>
- Date: Thu, 12 Feb 2009 13:14:45 -0800
On Feb 12, 2009, at 1:07 PM, Joel Reymont wrote:
On Feb 12, 2009, at 8:50 PM, Josh Graessley wrote:
In my experience, there are two good reasons to use a thread:
1) You're CPU bound so you need to utilize multiple cores
2) You're using a poorly designed API - synchronous APIs are a good
example
I'm with you Josh! How do I get notified that there's data to be
read from a socket _without_ using a separate thread and without
busy-polling?
I don't know if CFSocket allocates a single buffer and reuses it,
for example.
I want to use a single buffer of an exact size and I don't need
NSData back.
It looks like I need to use the BSD socket API but I suspect that
checking the socket every time my audio playback callback is
triggered may not be optimal. I'd rather check the socket, receive
data and post it to a buffer outside of my audio callback.
Can this actually be done without using a separate thread?
Thanks, Joel
Well, CFReadStream will do this, assuming you are using a runloop.
But behind the scene's, it makes a separate thread for calling the bsd
networking api's (at least on Mac OS X, but it's probably the same on
the iPhoneOS).
Eli
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden