My iOS app requires socket communication. I'm following this Ray Wenderlich tutorial for setting up the input and output streams. The server I'm using is Twisted. My app requires sending and receiving fast bursts of data generated by external events like gyroscope data. It is sending/receiving data in form of JSON string. So largely, it's very much like a real-time messaging chat app but sending and receiving is very fast and in bursts.
Now I know that streams don't send message-wise and instead send everything appended one after the other. But this thing I observed when sending data very fast. The Simulator's outputstream, even if it sends data very fast or not to an iPhone, in any case, sends data message-wise. And the server receives each send command as a single message. Unlike when an iPhone running the same code, when it has to send data fast, it sends all messages like a stream, appended one after the other.
Moreover, when the Simulator sends the the messages fast, the receiving iPhone gets all the messages and complete messages. But when an iPhone sends fast messages to a Simulator or another iPhone, both receive incomplete/broken messages, even if the code at server separates the stream appended messages before sending(which has been verified by me).
Can anyone explain me whats wrong and where? I want my app to receive fast and complete messages not only from simulator but also from another iPhone.
This is the original question that I have posted in case anyone is interested in details.