Re: Asynchronous sockets?
Re: Asynchronous sockets?
- Subject: Re: Asynchronous sockets?
- From: Duane Murphy <email@hidden>
- Date: Wed, 6 Feb 2002 16:34:29 -0800
--- At Wed, 6 Feb 2002 16:18:23 -0800, Douglas Davidson wrote:
>
On Wednesday, February 6, 2002, at 03:56 PM, Duane Murphy wrote:
>
>
>> If you're in an app with a CFRunLoop, I believe you can use CFSocket.
>
>> I'm
>
>> not familiar with either, so I can't help much beyond that.
>
>
>
> Ah, run loop polling instead. I expect that all CFSocket does is call
>
> select() in the run loop? I suppose that could be convenient for some
>
> applications.
>
>
The idea of the run loop is to avoid polling. The current
>
implementation of CFSocket maintains a single private thread which calls
>
select(), and then wakes up the relevant run loops as necessary. This
>
is an implementation detail; future implementations might be able to
>
dispense with the additional thread. However, they still will not use
>
the processor in the absence of socket activity.
Thanks for the information David.
This sounds like a possibility. We arent in a position to use a run loop
for this particular application, but the implementation is helpful. I
guess you have to make the select() thread so dead simple that killing it
wont cause any problems. (I tend to think in terms of C++ and killing C++
makes me nervous.)
--- At Wed, 6 Feb 2002 16:04:27 -0800, Douglas Davidson wrote:
>
For example, you can make your
>
threads select not only on their own sockets, but also on one or more
>
local "wakeup" sockets. When you want a thread to halt or do something
>
else, write to an appropriate wakeup socket; the thread returns from
>
select, notices it's been woken up, and checks some flag to determine
>
what it should do.
This is also an interesting alternative, however it seems that it is not
only more complex but not very self contained. I like nice self-contained
packages. It might be worth an experiment or two though.
Thanks for the suggestions,
...Duane
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.