'A port created with L{IReactorTCP.listenTCP} can be connected to with
L{IReactorTCP.connectTCP}.'

def test_closePortInProtocolFactory(self):

    f = ClosingFactory()
    port = reactor.listenTCP(0, f, interface='127.0.0.1')
    f.port = port
    self.addCleanup(f.cleanUp)
    portNumber = port.getHost().port
    clientF = MyClientFactory()
    reactor.connectTCP('127.0.0.1', portNumber, clientF)
    def check(x):
        self.assertTrue(clientF.protocol.made)
        self.assertTrue(port.disconnected)
        clientF.lostReason.trap(error.ConnectionDone)
    return clientF.deferred.addCallback(check)
