Suppose I want to run a TCP/IP service on some port for IPC. As I'm passing the port number to the processes I want to communicate with anyway, the port number doesn't matter. What's the best way to get a random, high (usually >49152) port number that is still available from the system? Is there something in POSIX I can use?
I know FTP servers need this frequently.