<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div>Hi,<br><br>I'm using TCP to pass large files back and fourth.&nbsp; So far I've follow and expanded on the twisted code examples for a simple server/client.&nbsp; <br>Everything works fine for me until the packets get large enough that fragmentation kicks in.<br><br>From one side, I'm sending packets like so:<br><br>class EchoClient(protocol.Protocol):<br>&nbsp;&nbsp;&nbsp; def connectionMade(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data = ""<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while len(data) &lt; 10000:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data=data+'a'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.transport.write(data)<br><br><br>and on the receiving end:<br><br>def dataReceived(self,
 data):<br>&nbsp;&nbsp;&nbsp; print data<br><br><br>I noticed after multiple iterations the data buffer fills up to the total 10000 bytes, but this takes 3 iterations of dataReceived().&nbsp; Common sense suggests to have a simple "if len(data) == totalPacketSize" to solve my problem, but I have different sized packets coming in all the time, and can't hardcode this part.<br><br>I was wondering if there's any way in Twisted/Python to handle packet fragmentation.&nbsp; Can I access the last fragment flag in the TCP packet somehow? Or is there a total packet size sent with the packet automatically?<br>If not, what would be the best way to solve this?<br><br>thanks,<br><br>Nima<br></div></div></body></html>