Hi,<div><br></div><div>I wrote a server using a protocol that inherit from &#39;basic.LineReceiver&#39;.</div><div><br></div><div>In some circonstances I need  to reject the data send by the client and to close the connection. Here is how I do that:</div>
<div><br></div><div>class MyProtocol(basic.LineReceiver):</div><div><br></div><div>    ........</div><div><br></div><div>    def error(self, error_msg):</div><div>        self.transport.write(error_msg)</div><div>        self.transport.loseConnection()</div>
<div><br></div><div><br></div><div>Sometimes it works: the client gets notify of the error and the connection is closed properly.</div><div>And some other times, the client does not received the error notification and the server closes the connection, which causes the client (wich is not written using twisted, but with the socket module from the standard lib) to crash with &#39;socket.error: (10054, &#39;Connection reset by peer&#39;)&#39;.</div>
<div><br></div><div>As I red somewhere in the docs or in the mailing list, self.transort.write does can return before it really writes the data. </div><div><br></div><div>So how could I do, without using blocking code, to wait until self.transort.write effectively writes the data to avoid closing the connection with unwritten data ?</div>
<div><br></div><div>Thanks you.</div><div><br></div><div>Emmanuel</div><div><br></div><div><br></div>