[launchd-dev] Dynamic port listening

Hamish Allan hamish at gmail.com
Mon Nov 12 11:11:35 PST 2007


Hi,

Is it possible to make a LaunchAgent listen on the first free port
rather than a specific one?

I'm trying to forward an HTTP connection on demand (over SSH), but
rather than choose a specific local port I'd rather just choose a free
one and then advertise it using Bonjour. So I also need to know what
the chosen port was and pass it to dns-sd.

A related question: is it possible (without writing to /etc/services)
to make LaunchAgent listen on a port decided dynamically? i.e. would
it be possible to use NAT-PMP to forward an external port to the first
available local port, and then have a LaunchAgent listen on that port?

Thanks,
Hamish


More information about the launchd-dev mailing list