code: 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)
docs: 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.