<div dir="ltr">
















<p class="MsoNormal"><span style="color:rgb(30,63,16)">Hi
All,</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">I
have a two-part question I was hoping someone smarter than me could help out
with. :)</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">1.
Please find attached Python script. We have integrated the Twisted
framework with iOS for chat module. Attached is our Python demo code in which
we have implemented this. The issue is when we try to connect with the server
through the terminal, we are getting the complete correct response without any
error. But when it was integrated on the iOS app, data is getting received in
chunks (i.e. if data exceeds 1366 bytes or above in json size it comes in
pieces which creates a problem when sending and receiving chats)</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">2.
Please find attached the iOS source code for Socket programming.</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">In
this we have used sample code of iOS for Socket communication.</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Once
you run the app it will try auto-connecting to server and, once the connection
is established with server it will show the "GetData" button.</span></p>

<p class="MsoNormal"><span style="color:rgb(57,62,63)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Using
this button you can hit one command with the server chat module and in
response, the app will get the data from the server.</span></p>

<p class="MsoNormal"><span style="color:rgb(57,62,63)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">The
issue here is we are not able to get all of the response data at once as it
gets distributed into packets and sent to the client one-by-one. When we are
getting this data alone in a number of packets then there is no problem
reconstructing it. But when the server is sending 2-3 different types of
datasets on the same socket then the different data packets are not sequential,
meaning it's not sending data2 first and once finished sending data3 it will
send data3. These data2 and data3 packets get mixed and the client is getting
the example shown below:</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Data2
Packets: </span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet2_1</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet2_2</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet2_3</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet2_4</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Data3
Packets: </span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet3_1</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet3_2</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet3_3</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet3_4</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Receiving
Order:</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet2_1</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet2_2</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet3_1</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet2_3</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet3_2</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet3_3</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet2_4</span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">Packet3_4</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)"> </span></p>

<p class="MsoNormal"><span style="color:rgb(30,63,16)">As
you can see the receiving order is that of two different data sets, which we
are not able to reconstruct due to the wrong sequence of packets.</span><span style="color:rgb(57,62,63)"></span></p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">If any of this is confusing/requires further explanation,
just let me know. Also, if there is a better forum for me to direct this
question just let me know as well.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Thank you in advance for your help!</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">-Adam</p>


</div>