Suppose you have a CFWriteStream that you call CFWriteStreamClose() on immediately after calling CFWriteStreamWrite(). Both calls are made on the same thread. Will the close operation guarantee that any bytes written to/buffered by the stream are in fact sent to the recipient before the stream is destroyed?
In short, does calling CFWriteStreamClose() flush the stream?
According to the documentation, no it does not. It "terminates the flow of bytes" on the stream. While CFWriteStreamWrite is synchronous, it does not guarantee that all bytes you want to write will be written in one call. Thus it returns the number of bytes actually written; your job is to keep calling it until your data is exhausted or you otherwise decide to stop.
Calling the close function is designed to clean up any resources associated with the stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With