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

Steve Freitas sflist at ihonk.com
Thu Aug 25 10:35:30 EDT 2005

Hi David,

Thanks for the reply. I'm aware of using loseConnection() from inside
the protocol, but I'm using PBServerFactory. So I'm looking for a way to
choose an arbitrary PB client that's already connected and logged in
(cred) through that factory and kill the connection -- in other words,
of all the clients that may be connected to that factory, I need to know
how to get the transport that I want, so I can call loseConnection() on

If I need to subclass PBServerFactory, that's fine, but I'm hoping to
find something a little more direct.



On Thu, 2005-08-25 at 11:12 -0300, David Guaraglia wrote:
> 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
> >  
> >
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list