Hi All<div><br></div><div>  A few months ago, I reported a bug about IOCP. Last night I spent several hours on its implementation and finally found out a possible solution for that.</div><div><br></div><div>  when sending some small chunks data continuously, the buffer will pile them up and send to IOCP; however there is a SEND_LIMIT (128K) that means only 128K will be handled. Now the problem is when we try to trigger the next writing, IOCP will raise ERROR_IO_PENDING immediately and then connection Lost.</div>
<div><br></div><div>  So I got a idea: if the size of data is larger than SEND_LIMIT, we can wait a little bit time for the next writing instead of do it immediately. </div><div><br></div><div>in twisted\internet\iocpreactor\abstract.py there is a method</div>
<div><br></div><div><div>def _cbWrite(self, rc, bytes, evt):</div><div>        if self._handleWrite(rc, bytes, evt):</div><div>            self.doWrite()</div></div><div><br></div><div>now I modified a bit,</div><div><br>
</div><div><div>def _cbWrite(self, rc, bytes, evt):</div><div>        if self._handleWrite(rc, bytes, evt):</div><div>            if len(evt.buff) &lt; self.SEND_LIMIT:</div><div>                self.doWrite()</div><div>            else:</div>
<div>                self.reactor.callLater(0.8,self.doWrite)</div></div><div><br></div><div><br></div><div><br></div><div>0.8 is a silly trial but I have no idea what is the right number for this place. After this modification, previous problematic scripts can pass.</div>
<div><br></div><div>Maybe the better solution is to find a way to poll the complete port status when read/write will be recovered from IO PENDING. Simply wait a little is risky.</div><div><br></div><div>Regards</div><div>
<br></div><div>gelin yan</div>