Re: Closing CFWriteStreams (re-sent)
Re: Closing CFWriteStreams (re-sent)
- Subject: Re: Closing CFWriteStreams (re-sent)
- From: Terry Lambert <email@hidden>
- Date: Thu, 19 Jun 2008 19:02:23 -0700
On Jun 19, 2008, at 6:35 PM, Eli Bach wrote:
How can I do an orderly vs a disorder TCP disconnect using
CFWriteStream in my daemon?
If I CFWriteStreamClose() immediately after my last
CFWriteStreamWrite(), the data may or may not get sent out.
From the documentation, I gather that CFWriteStream buffers data
internally before actually sending it down the wire, and I can query
it if I can add data to the buffer, but there doesn't seem to be a
way to query if that write buffer is empty, or to flush the buffer
before closing the stream.
I'm using CFRead/WriteStreams using events on a single runloop.
You do not give enough information about how you got it associated
with the stream in the first place, but typically, you can do a:
CFWriteStreamCopyProperty( stream, kCFStreamPropertySocketNativeHandle)
and then call shutdown(2) on the fd you get back.
It may also do this automatically in the close, if you set the socket
back to blocking, if you are using it non-blocking. Typically, a
close flushes buffered output before returning.
See also:
<http://developer.apple.com/documentation/Networking/Conceptual/CFNetwork/CFNetwork.pdf
>
which shows up in the first page of google results for
"CFWriteStreamClose socket".
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden