(reactor)
Returns a Deferred firing an available TCP port on localhost.
    It does so by listening on port 0; then stopListening and fires the
    assigned port number.
Returns a Deferred firing an available TCP port on localhost.
    It does so by listening on port 0; then stopListening and fires the
    assigned port number.
Returns a Deferred firing an available TCP port on localhost . It does so by listening on port 0 ; then stopListening and fires the assigned port number .
def available_tcp_port(reactor):
    """
    Returns a Deferred firing an available TCP port on localhost.
    It does so by listening on port 0; then stopListening and fires the
    assigned port number.
    """

    endpoint = serverFromString(reactor, 'tcp:0:interface=127.0.0.1')
    port = yield endpoint.listen(NoOpProtocolFactory())
    address = port.getHost()
    yield port.stopListening()
    defer.returnValue(address.port)
def available_tcp_port ( reactor ) : endpoint = serverFromString ( reactor , 'tcp:0:interface=127.0.0.1' ) port = yield endpoint . listen ( NoOpProtocolFactory ( ) ) address = port . getHost ( ) yield port . stopListening ( ) defer . returnValue ( address . port )