def find_free_port
      socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
      socket.listen(1)
      port = socket.local_address.ip_port
      socket.close
      port
    end
def find_free_port
      socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
      socket.listen(1)
      port = socket.local_address.ip_port
      socket.close
      port
    end
Private: Finds a free port by asking the kernel for a free one

 Returns a free port number