TCP combine two messages when no ack is received
<p>I want to send from the server (in java) two messages:</p>

<pre><code>send: 0x01
Sleep: 5 seconds
send: 0x02
</code></pre>

<p>The client is an iPhone app, and sometimes, when the app is in background, it take 5-10 seconds to send server an ack, and TCP sends the first message AND the seconds message in ONE PACKET, it go's as following:</p>

<pre><code>Time 00:00:00    server sends 0x01 - and wait for ack
Time 00:00:05    server not received ack and it needs to send the second message, so the server send: 0x01 0x02
</code></pre>

<p>Then the client don't know what this message mean, and sends FIN.</p>

<p>Any suggestions?</p>

<p>I've looked in <a href="http://docs.oracle.com/javase/1.4.2/docs/guide/net/socketOpt.html" rel="nofollow">this</a> page to find any option to avoid this chaining. May be you will find something related for this issue.</p>

<p>Thanks in advance.</p>
