<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>Thanks for the detailed information!<br><br>I tried it out with LineReceiver and everything worked great!<br><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">-Nima<br><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;">----- Original Message ----<br>From: "glyph@divmod.com" &lt;glyph@divmod.com&gt;<br>To: Twisted general discussion &lt;twisted-python@twistedmatrix.com&gt;<br>Sent: Wednesday, October 8, 2008 4:13:18 PM<br>Subject: Re: [Twisted-Python] Packet Fragmentation<br><br><br>On 10:51 pm, <a ymailto="mailto:nimag@rogers.com" href="mailto:nimag@rogers.com">nimag@rogers.com</a> wrote:<br>&gt;I was wondering if there's any way in Twisted/Python to handle packet <br>&gt;fragmentation.&nbsp; Can I access the last fragment
 flag in the TCP packet <br>&gt;somehow? Or is there a total packet size sent with the packet <br>&gt;automatically?<br>&gt;If not, what would be the best way to solve this?<br><br>What you're dealing with here is not packet fragmentation.&nbsp; TCP packet <br>fragmentation is a very specific phenomenon that occurs at a lower level <br>than Twisted (and your application).<br><br>When you send a large message over a TCP stream, it can get broken up <br>into multiple segments.&nbsp; That's not the same as an individual packet <br>getting fragmented.&nbsp; There's no way to re-assemble the message to <br>discover the original boundaries of the "write" call that you used to <br>emit it.<br><br>In other words, your data stream needs to have message boundaries in it. <br>TCP, at the application level, is a stream of octets, *not* a sequence <br>of packets.<br><br>There are numerous examples of this in Twisted; for example, <br>twisted.protocols.basic includes
 NetstringReceiver, LineReceiver and <br>(various subclasses of) IntNStringReceiver, each of which is a different <br>strategy for breaking up a TCP stream into a discrete sequence of <br>messages.<br><br>_______________________________________________<br>Twisted-Python mailing list<br><a ymailto="mailto:Twisted-Python@twistedmatrix.com" href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br></div></div></div></body></html>