'The connection was lost.
This is called when the connection on a selectable object has been
lost.  It will be called whether the connection was closed explicitly,
an exception occurred in an event handler, or the other end of the
connection closed it first.
Clean up state here, but make sure to call back up to FileDescriptor.'

def connectionLost(self, reason):

    self.disconnected = 1
    self.connected = 0
    if (self.producer is not None):
        self.producer.stopProducing()
        self.producer = None
    self.stopReading()
    self.stopWriting()
