'Return a L{Deferred} firing with a L{MyClientFactory} and
L{MyServerFactory} connected pair, and the listening C{Port}.'

def getConnectedClientAndServer(self, reactor, interface, addressFamily):

    server = MyServerFactory()
    server.protocolConnectionMade = Deferred()
    server.protocolConnectionLost = Deferred()
    client = MyClientFactory()
    client.protocolConnectionMade = Deferred()
    client.protocolConnectionLost = Deferred()
    port = reactor.listenTCP(0, server, interface=interface)
    lostDeferred = gatherResults([client.protocolConnectionLost, server.protocolConnectionLost])
    def stop(result):
        reactor.stop()
        return result
    lostDeferred.addBoth(stop)
    startDeferred = gatherResults([client.protocolConnectionMade, server.protocolConnectionMade])
    deferred = Deferred()
    def start(protocols):
        (client, server) = protocols
        log.msg(('client    connected    %s' % client))
        log.msg(('server    connected    %s' % server))
        deferred.callback((client, server, port))
    startDeferred.addCallback(start)
    reactor.connectTCP(interface, port.getHost().port, client)
    return deferred
