robbiehanson/CocoaAsyncSocket — Issue #4: readDataWithTimeout: reads are sometimes returning truncated data
Author: apexfork
Created: 2011-12-06 14:47:36+00:00
State: open

I noticed my reads for all data were being truncated (not every time, but anecdotally it was more likely on longer reads)

So after noticing there were different code paths for the three different kinds of reads, I just changed the logic of my client/server protocol to add a ZeroData at the end of transmission and to receive using readData:toData, thus forcing me into the read-to-terminator code path. Now my reads always return complete data.

If I find time to track this bug down, I will, but thought I should report it.

One possibility I didn't consider until just now: if socket:didReadData:withTag: is called for each "chunk" of data in the read, with the expectation that the delegate will handle the partials, then this is functioning as expected, and the documentation needs to be updated.