Re: CFReadStream not giving me any data
Re: CFReadStream not giving me any data
- Subject: Re: CFReadStream not giving me any data
- From: Jeremy Wyld <email@hidden>
- Date: Wed, 25 Feb 2004 07:38:35 -0800
CFSocketStream is not guaranteed to work with anything but TCP-based
sockets.
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?
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.