<div dir="ltr">Oh I was having trouble because my fileno() method was not returning the correct descriptor. But I fixed it...<div><br></div><div>Thanks for the excellent suggestion for improving performance!</div><div>I've implemented that change. It works great!</div>
<div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 1, 2013 at 5:38 AM,  <span dir="ltr"><<a href="mailto:exarkun@twistedmatrix.com" target="_blank">exarkun@twistedmatrix.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 07:30 am, <a href="mailto:dstainton415@gmail.com" target="_blank">dstainton415@gmail.com</a> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I'm trying to implement an IWriteDescriptor using raw sockets.<br>
So far this is what I wrote... but it doesn't work:<br>
<a href="https://github.com/david415/hushTCP/blob/master/hush_writer.py" target="_blank">https://github.com/david415/<u></u>hushTCP/blob/master/hush_<u></u>writer.py</a><br>
<br>
Am I doing something obviously wrong here?<br>
<br>
I certainly am able to use raw socket + scapy correctly without Twisted.<br>
</blockquote>
<br></div></div>
Please describe the problem in more detail than "it doesn't work". >:) Your hush_writer.py is a good <<a href="http://sscce.org/" target="_blank">http://sscce.org/</a>> but it's still important to know how its behavior differs from your expectations.<br>

<br>
As far as I can tell it does work - although there's one mistake that makes it a bit more inefficient than strictly necessary:<br>
<br>
    def doWrite(self):<br>
        if len(self.packets) > 0:<br>
            self.socket.sendto(self.<u></u>packets.pop(0), self.address)<br>
        else:<br>
            return<br>
<br>
When you're out of packets you should remove the writer from the reactor.  This version of the code will perpetually dispatch writeable notification (in the form of a doWrite call) to your object as fast as possible.<br>

<br>
Once you fix this, don't forget to re-add the writer as soon as len(self.packets) rises above 0 again.<br>
<br>
Jean-Paul<div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<u></u>_________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.<u></u>com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-<u></u>bin/mailman/listinfo/twisted-<u></u>python</a><br>
</div></div></blockquote></div><br></div>