CocoaAsyncSocket and reading data from a socket
问题 On my TCP-socket based server, I send a packets over the stream where packets consist of a header specifying the number of bytes in the packet, followed by that number of bytes. For those familiar with Erlang, I'm simply setting the {packet, 4} option. On the iOS side, I have code that looks like this, assuming I want to figure out the size of the stream for this message: [asyncSocket readDataToLength:4 withTimeout:-1 tag:HEADER_TAG]; That works fine and the following delegate method callback