[Twisted-Python] How to forcibly disconnect PB client?

David Guaraglia dguaraglia at gmx.de
Thu Aug 25 10:12:22 EDT 2005


Hi Steve,

It depends, if you decide you should disconnect the client while 
processing data in the Protocol, then you can just 
"self.transport.loseConnection()".

(e.g):
class MyProt(Protocol):
    dataReceived(data):
       if data <> "hello":
          self.transport.loseConnection()
       else:
          ....

So the most important question is: where do you decide that you should 
disconnect the client?

Hope this helps,

David

Steve Freitas wrote:

>Hi,
>
>In some cases I need to force a client to disconnect. Is there some
>factory call that I can use to do this? On the client side, I know I can
>use factory._broker.transport.loseConnection(), but on the server side,
>though I've looked at the source a bit, I'm not sure how to get at the
>correct transport.
>
>Thanks!
>
>Steve
>  
>





More information about the Twisted-Python mailing list