<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. So far I've follow and expanded on the twisted code examples for a simple server/client. <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> def connectionMade(self):<br> data = ""<br> while len(data) < 10000:<br> data=data+'a'<br> self.transport.write(data)<br><br><br>and on the receiving end:<br><br>def dataReceived(self,
data):<br> 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(). 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. 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>