'Listen on a port, and immediately stop listening as a way to find a
port number that is definitely closed.'

def test_PORTCannotConnect(self):

    d = self._anonymousLogin()
    def loggedIn(ignored):
        port = reactor.listenTCP(0, protocol.Factory(), interface='127.0.0.1')
        portNum = port.getHost().port
        d = port.stopListening()
        d.addCallback((lambda _: portNum))
        return d
    d.addCallback(loggedIn)
    def gotPortNum(portNum):
        return self.assertCommandFailed(('PORT    ' + ftp.encodeHostPort('127.0.0.1', portNum)), ["425    Can't    open    data    connection."])
    return d.addCallback(gotPortNum)
