Re: POSIX sockets and event loops
Re: POSIX sockets and event loops
- Subject: Re: POSIX sockets and event loops
- From: "Duane Murphy" <email@hidden>
- Date: Thu, 20 May 2004 17:13:12 -0700
--- At Thu, 20 May 2004 17:33:06 -0500, Aaron Ballman wrote:
>
>I should clarify. I'm not using Carbon Events. I am using the
>
>CFSocketCreateRunLoopSource() and run loops. I think that's what you want
>
>to use in order to detect network I/O.
>
>
Ah, but unfortunately I am not using any of the CFSocket stuff
>
because the socket code itself is meant to run on Linux as well as OS
>
X and Windows (with minor tweaks because Windows tends to not be very
>
POSIX-friendly in some cases). So I am trying to stick as close to
>
POSIX as I can so I don't have to maintain too many different code
>
forks.
I would take a look at CFSocket. It's not a large investment and I am
pretty certain that you can isolate the code from the POSIX code. As it
is now it sounds like you're polling select() in order to find out if
there is network I/O.
In this case, the system would do the polling for you and then notify you
of that I/O instead. CFSocket is a very shallow layer over a socket. You
can still use the raw socket for everything. You'll have to arrange
CFSocket so that it doesn't close the socket for you. But that's pretty
straightforward as well.
The only other suggestion I might have is to use the more classic Unix
networking technique of putting all the networking into another thread.
You then have to use some other technique to get UI information from the
networking thread to the main (UI) thread.
Good luck,
...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.