[launchd-dev] Dynamic port listening
Dave Zarzycki
zarzycki at apple.com
Mon Nov 12 11:15:02 PST 2007
On Nov 12, 2007, at 11:11 AM, Hamish Allan wrote:
> Hi,
>
> Is it possible to make a LaunchAgent listen on the first free port
> rather than a specific one?
Sure, set the port to zero. The kernel will dynamically assign a free
port.
>
>
> 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.
Actually, the launchd code should handle that for you. Just set
Bonjour to true in the plist.
>
>
> 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?
I'm not sure what NAT-PMP is or how it applies to this scenario…
davez
More information about the launchd-dev
mailing list