Re: CFReadStream not giving me any data
Re: CFReadStream not giving me any data
- Subject: Re: CFReadStream not giving me any data
- From: Dave Camp <email@hidden>
- Date: Wed, 25 Feb 2004 08:06:19 -0800
On Feb 25, 2004, at 7:38 AM, Jeremy Wyld wrote:
CFSocketStream is not guaranteed to work with anything but TCP-based
sockets.
Well. That's not what I wanted to hear... :-(
Having said that, this should work. Does netstat show bytes waiting in
the recv queue on the client? If so, does the stream think it has
bytes? Manually poll CFReadStreamHasBytesAvailable to see if it says
yes or no. If that fails, perform a select on the socket and see if
it succeeds.
I noticed that you are only scheduling the read streams. Is there
missing code here or are you using read async and write sync?
Async read (on a separate thread) and sync writes.
In any event, if this isn't officially supported, then I shouldn't be
doing it in a major shipping product. This is disappointing as the
Stream API's were quite enticing.
Can someone suggest a good book or tutorial website on BSD sockets? The
man pages for socket, accept, etc talk about the individual routines
but I'm looking for something that describes how they all work together
and proper usage.
Thanks,
Dave
jeremy
On Feb 24, 2004, at 11:34 AM, Dave Camp wrote:
I'm prototyping some CFStream code that will use unix domain sockets
to communicate between two processes. For testing, I've got a server
app and a client app. The sequence of events looks something like:
- Server creates socket with CFSocketCreateWithSocketSignature
- Client connects with:
CFSocketCreateConnectedToSocketSignature
CFStreamCreatePairWithSocket
CFReadStreamSetClient(
kCFStreamEventOpenCompleted | kCFStreamEventHasBytesAvailable |
kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered)
CFReadStreamScheduleWithRunLoop(readStreamRef,
CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
CFReadStreamOpen
CFWriteStreamOpen
- Server accept callback is called and it does:
CFStreamCreatePairWithSocket
CFReadStreamSetClient(
kCFStreamEventOpenCompleted | kCFStreamEventHasBytesAvailable |
kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered)
CFReadStreamScheduleWithRunLoop(readStreamRef,
CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
CFReadStreamOpen
CFWriteStreamOpen
- Client and Server callbacks are both called with
kCFStreamEventOpenCompleted
- Server writes a string with CFWriteStreamWrite
And that's about where it ends. The client is never called with
kCFStreamEventHasBytesAvailable. At this point, both apps are sitting
idle in their runloops waiting for something to happen. No errors are
detected on any of the calls leading to this point.
If I kill the client, the server gets kCFStreamEventHasBytesAvailable
with zero bytes and kCFStreamEventEndEncountered, as expected. I can
also successfully write from the client to the server. If I kill the
server first, the client does not get any callbacks. It's as if the
pipes are only open one way or something.
Any thoughts on why the client would get a
kCFStreamEventOpenCompleted, but no further messages?
Dave
---
The path of least resistance, it's not just for electricity any more.
_______________________________________________
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.
_______________________________________________
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.