Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does CFWriteStreamClose() Flush?

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?

like image 648
aroth Avatar asked May 11 '26 00:05

aroth


1 Answers

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.

like image 118
lyricsboy Avatar answered May 12 '26 15:05

lyricsboy