Re: how to use the same udp port already loaded by launchd?
Re: how to use the same udp port already loaded by launchd?
- Subject: Re: how to use the same udp port already loaded by launchd?
- From: Ian Mark Salvame <email@hidden>
- Date: Thu, 16 Jul 2009 05:09:34 -0700 (PDT)
>> Is it proper to unload and load launchd agents programatically?
>> Are there any APIs to do that?
>
> Unfortunately there aren't any APIs for this. What you have to do is run the 'launchctl' tool (using either NSTask, or fork+execv.) See "man launchctl" for > > details.
>
> If the agent is being managed by the root instance of launchd (i.e. its service is defined in /Library/LaunchAgents) then you will need to run launchctl as > > root, using the authorization API. But if it's a per-user agent defined in ~/Library/LaunchAgents, you can just invoke launchtcl normally to control
it.
>
> By the way, what exactly are you trying to do? I can't think of a good reason why you'd need to do this; it's possible you're headed down the wrong path.
>
> —Jens
Actually this is the scenario why I'm doing this:
I have a client app binding port12345 for sending packets to a certain server.
The server will store the client's port number(that is 12345).
Then the client closes and quits.
I have a launchd agent which is different from the client app but located in the same host.
This launchd agent will be listening to port12345, so if the server sends a packet using the stored port number(12345)
the launchd agent will launch and read the packet.
The problem is, that when the client app lauches again it will fail to bind port12345.
I want the client app for sending, while the luanchd agent for receiving from the server.
Is there another way to do this?
I don't want
to have a running process to listen from the server, that is why I am using a launchd agent.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden