[Twisted-Python] Python Twisted Questions

Adam adam at dormchatapp.com
Tue Dec 2 15:30:15 MST 2014


Hi All,



I have a two-part question I was hoping someone smarter than me could help
out with. :)



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)



2. Please find attached the iOS source code for Socket programming.



In this we have used sample code of iOS for Socket communication.



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.



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.



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:



Data2 Packets:

Packet2_1

Packet2_2

Packet2_3

Packet2_4





Data3 Packets:

Packet3_1

Packet3_2

Packet3_3

Packet3_4





Receiving Order:

Packet2_1

Packet2_2

Packet3_1

Packet2_3

Packet3_2

Packet3_3

Packet2_4

Packet3_4



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.





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.



Thank you in advance for your help!



-Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20141202/73b71f0f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demo.py
Type: text/x-python-script
Size: 8515 bytes
Desc: not available
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20141202/73b71f0f/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SocketSampleDemo.zip
Type: application/zip
Size: 36445 bytes
Desc: not available
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20141202/73b71f0f/attachment-0001.zip>


More information about the Twisted-Python mailing list