Does anyone know how the CFSocket API reads bytes from the socket into the data callback? I thought at first it would do some "under the hood" work to always return the data in the same length as it was sent but after some testing I found that data was returned in chunks if I sent lots of data quickly so I needed to parse the packets myself using a header.
So far in testing I haven't received any partial data (i.e. if I sent 1000 bytes I always get 1000 in the data callback but never less) but I imagine if the buffer got really full this could happen and I would have to rebuild packets if they were incomplete.
Do I basically need to be using the same packet reading strategy with CFSocket that I would use with BSD sockets, i.e. prefix each packet with a header including length, parse the stream up the packet length and recombine data if the packet was incomplete upon the callback being called again.
Thanks!