The bound stream pair works such that you can write in chunks into the write stream and something else can read in chunks from the read stream. You've set transferBufferSize
to 4096 here. This indicates that the data will be moved from the write stream to the read stream in chunks of 4096 bytes (4K). If your source data is >4K but <8K in length, that would explain why you're only getting the first 4K of it. If, say, your data is 6K long, then the first 4K will be sent to the read stream, then the next 2K will be queued up, but my understanding is that it will sit waiting in a buffer until one of two things happen:
- Enough data arrives to complete a second 4K block.
- The write stream is closed.
So if 6K is all you're ever going to write to the write stream, then you need to close the write stream with CFWriteStreamClose(oStream);
in order for the last 2K to be sent to the read stream. Otherwise, my expectation would be that it would just sit there forever.