Don't brute force the port number, have the OS give you one directly.