'Transfer bytes back and forth between two TLS protocols.'

def flushTwoTLSProtocols(self, tlsProtocol, serverTLSProtocol):

    for i in range(3):
        clientData = self.drain(tlsProtocol.transport, True)
        if clientData:
            serverTLSProtocol.dataReceived(clientData)
        serverData = self.drain(serverTLSProtocol.transport, True)
        if serverData:
            tlsProtocol.dataReceived(serverData)
        if ((not serverData) and (not clientData)):
            break
    self.assertEqual(tlsProtocol.transport.value(), '')
    self.assertEqual(serverTLSProtocol.transport.value(), '')
