[Twisted-Python] Clossing one TCP connection

Jp Calderone exarkun at divmod.com
Wed Apr 27 19:57:09 EDT 2005

On Wed, 27 Apr 2005 20:10:29 -0300, Carolina Ardohain <carolinaardohain at gmail.com> wrote:
>I launch several connections using an object like this
>class MyConnection()
>  def __init__(host, port, factory):
>    self.factory = factory
>    self.connector = reactor.connectTCP(host, port, factory)
>I create several connections
>m1 = MyConnection('host1', 8000, MyFactory())
>m2 = MyConnection('host2', 8000, MyFactory())
>Now I want to create a method onClose that close the connection,
>something like reactor.stop() but that dont close the whole

  self.connector has a method, disconnect, that you can call to sever the connection associated with just that connector.  The object reactor.connecTCP() returns conforms to the IConnector interface, which is documented further here:



More information about the Twisted-Python mailing list