¡@

Home 

2014/10/15 ¤U¤È 10:13:09

iphone Programming Glossary: readdatatolength

CocoaAsyncSocket and reading data from a socket

http://stackoverflow.com/questions/6784872/cocoaasyncsocket-and-reading-data-from-a-socket

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 is invoked onSocket didReadData.. server side readLength does indeed read 12 on the client also so all is good so far. I proceed with the following sock readDataToLength readLength withTimeout 1 tag MESSAGE_TAG At this point though the callback onSocket didReadData withTag is no longer invoked... out its size UPDATE I changed my client and it seems to be working now. The problem is I don't understand the point of readDataToLength with the new solution. Here's what I changed my initial read to socket readDataWithTimeout 1 tag HEADER_TAG Now in my callback..