Posts

Post not yet marked as solved
5 Replies
643 Views
It looks like it was not there a while ago (except writing my own HTTP parser with low level networking APIs) and I do not see any recent documentation about it. But still hope to ask here in case I missed anything. Is there any plan or work in progress on this feature?
Posted
by mxyan.
Last updated
.
Post marked as solved
12 Replies
1.9k Views
Hi all!We got this problem with CFStream and hope to know if there's something we did not do correctly.We've been using CFStream to read a stream of large data. Each iteration we use CFReadStreamRead to read a block of 8KiB of data. If there's more data in the stream (exceeding the 8KiB buffer size), after processing the previous 8KiB, we read another 8KiB in the next interation using CFReadStreamRead.So we have been using the CFReadStreamClientCallBack to get the event of "HasBytesAvailable" as a trigger of reading more data. From our initial experiment it looked like if more than N bytes of data were received at once, if we call CFReadStreamRead with a buffer smaller than N bytes, CFReadStream issues another HasBytesAvailable callback. That was not surprising to us because there were still data left-over in the CFReadStream's buffer. So based on this behavior, we've build our logic to use the follow-up callback as the trigger of the next iteration.However recently we observed that sometimes a follow-up HasBytesAvailable callback is not issued even if CFReadStream's buffer has some left-over data (We confirmed by invoking CFReadStreamHasBytesAvailable() after the CFReadStreamRead call).Our question is, since we did not find any documentation about it, what is the expected callback behavior after a partial read? It looks like a follow-up callback is issued in most cases, but since the behavior is not consistent, we are struggling with the correct way to handle this thing. If we check CFReadStreamHasBytesAvailable(), it races with the callbacks.Would appreciate any pointer on this.Thanks!Muxi
Posted
by mxyan.
Last updated
.