Generate a random port number for the socket.