'Handle the possible repetition of calls to this method (due to either
the underlying transport going away or due to an error at the TLS
layer) and make sure the base implementation only gets invoked once.'

def connectionLost(self, reason):

    if (not self._lostTLSConnection):
        self._tlsConnection.bio_shutdown()
        self._flushReceiveBIO()
        self._lostTLSConnection = True
    reason = (self._reason or reason)
    self._reason = None
    self.connected = False
    ProtocolWrapper.connectionLost(self, reason)
