On Oct 6, 2005, at 5:39 PM, Ken Baer wrote: I am implementing a port of WinSock to the Mac using BSD sockets, and I have a function that is setting up the network event callbacks. I am creating a CFSocket from the SOCKET, setting up the callback types, creating a runloop source and adding it to the runloop. I have even taken steps to set the socket flags with CFSocketSetSocketFlags() to no automatically reenable the kCFSocketDataCallBack, and also called CFSocketDisableCallBacks() for kCFSocketDataCallBack.
I am getting callbacks, like Connect, and Write, but the problem is that I get kCFSocketDataCallBack, and NOT kCFSocketReadCallBack. My code wants to use the Read method, not the buffered Data method. Somehow it keeps getting turned on, even after I told it not to (bad, bad CFSocket!). Here is the code segment I am using to set this up. Is there another step to assure that it uses the Read callback and not the Data callback?
The header comments are pretty explicit here: kCFSocketReadCallBack, kCFSocketAcceptCallBack, and kCFSocketDataCallBack are mutually exclusive. You get to pick at most one of these. In particular, you can't use both kCFSocketReadCallBack and kCFSocketAcceptCallBack (as a glance at the constants should tell you).
Also, it says quite clearly that you should not disable callbacks that your CFSocket does not possess, so don't try to disable kCFSocketDataCallBack if you're not using it.
Douglas Davidson
|