'Create a port and connected client/server pair which can be used
to test factory behavior related to addresses.
@return: A L{defer.Deferred} which will be called back when both the
client and server protocols have received their connection made
callback.'

def setUp(self):

    class RememberingWrapper(protocol.ClientFactory, ):
        '\n                                                Simple    wrapper    factory    which    records    the    addresses    which    are\n                                                passed    to    its    L{buildProtocol}    method    and    delegates    actual\n                                                protocol    creation    to    another    factory.\n\n                                                @ivar    addresses:    A    list    of    the    objects    passed    to    buildProtocol.\n                                                @ivar    factory:    The    wrapped    factory    to    which    protocol    creation    is\n                                                                delegated.\n                                                '
        def __init__(self, factory):
            self.addresses = []
            self.factory = factory
        def buildProtocol(self, addr):
            '\n                                                                Append    the    given    address    to    C{self.addresses}    and    forward\n                                                                the    call    to    C{self.factory}.\n                                                                '
            self.addresses.append(addr)
            return self.factory.buildProtocol(addr)
    self.server = MyServerFactory()
    self.serverConnMade = self.server.protocolConnectionMade = defer.Deferred()
    self.serverConnLost = self.server.protocolConnectionLost = defer.Deferred()
    self.serverWrapper = RememberingWrapper(self.server)
    self.client = MyClientFactory()
    self.clientConnMade = self.client.protocolConnectionMade = defer.Deferred()
    self.clientConnLost = self.client.protocolConnectionLost = defer.Deferred()
    self.clientWrapper = RememberingWrapper(self.client)
    self.port = reactor.listenTCP(0, self.serverWrapper, interface='127.0.0.1')
    self.connector = reactor.connectTCP(self.port.getHost().host, self.port.getHost().port, self.clientWrapper)
    return defer.gatherResults([self.serverConnMade, self.clientConnMade])
