Re: Closing CFWriteStreams (re-sent)
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Terry, For the client, I use -- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Jun 19, 2008, at 8:23 PM, Eli Bach wrote: First, I resent the message because I didn't receive the first one from the list [and from way back, I expected to receive it]. I didn't complain about duplicate messages; however, realize that this is a mailing list, and you may have to wait days for an answer, if any. CFStreamCreatePairWithSocketToHost() CFReadStreamSetProperty(kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue CFWriteStreamSetProperty(kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue and the code picks up in the above outline at the same spot [and the code is shared between client and server]. Right now, it seems that using CFWriteStreamClose(), then releasing the stream with the above setup doesn't force the data stream to be flushed. I'll try switching 'kCFStreamPropertyShouldCloseNativeSocket' to false, then get the socket and do a close() or shutdown() on the socket explicitly. Of course, I hate the idea of needing to spin off another thread just to call close() [as it should block waiting for all the data to be sent, and would halt the runloop doing it there]. You need someone more fluent in CF than me. My response was specifically for data buffered in the socket, but not yet sent to the other end. If the socket is async and it is not explicitly shutdown, then you will potentially lose unbuffered sent data. I actually can' imagine that the CFWriteStreamClose() would not flush output data before the close returned. If the socket was async, though, a real close (or the process exitting) won't be blocked, if the socket is async. Or is there another, better way to do this? Personally, I'd follow the PDF example exactly. It looks to me like it waits until everything has been sent. This email sent to site_archiver@lists.apple.com
participants (1)
-
Terry Lambert