[launchd-dev] Confused about sockets - please help!

dreamcat four dreamcat4 at gmail.com
Wed Mar 3 07:42:23 PST 2010


Hi,
Thanks for the clarification.

Incidentally I found a nice pair of examples about it, to illustrate
these different kinds of Sockets nesting:

Example1: "/System/Library/LaunchDaemons/org.cups.cupsd.plist"
Example2: "/System/Library/LaunchDaemons/org.cups.cups-lpd.plist"



* 1 More Question - About "Listeners":

<key>Sockets</key>
<dict>
	<key>Listeners</key>        <--- *** this ***


Its used very commonly so im going to make it the "default". In the
documentation it says that deamon developers should not be sensitive
to this thing. *But* does launchd still let the deamon developer to
see this key name in the returned results? In which case, (and maybe
wrongly but nevertheless), they might end up writing some code that is
sensitive to this key name? You know, to find their results from it
and whatnot.

Therefore:
Is it better, worse, or no different to randomly generating the
multiple key names as "Listeners314986", "Listeners349q323" etc. ?

Heres how i must write my code otherwise, to decide whether or not to
throw an error over this:

# Method

def sockets(keyname="Listeners", &block)
  # here we create the Sockets xml from whats in "&block"
end


# Usage

# Create Plist scenario 1:
  sockets do
    sock_service_name "netbios-ssn"
  end

# => Result: Ok. "Listeners" toplevel key is generated implicitly.



# Create Plist scenario 2:
  sockets do
    sock_service_name "netbios-ssn"
  end
  sockets do
    sock_service_name "netbios"
    bonjour ['smb']
  end
# => Result: Exception error. because implicit "Listeners" key is
declared twice.



# Create Plist scenario 3:
  sockets "netbios-ssn" do
    sock_service_name "netbios-ssn"
  end
  sockets "netbios" do
    sock_service_name "netbios"
    bonjour ['smb']
  end

# => Result: Ok. Each Sockets entry has a unique key.



# Create Plist scenario 4:
  sockets[0] do
    sock_service_name "netbios-ssn"
  end
  sockets[1] do
    sock_service_name "netbios"
    bonjour ['smb']
  end

# => Result: Ok. Each Sockets entry has a unique array index. The
array of all sockets held within the "Listeners" toplevel key
(implicit).



# Create Plist scenario 5:
  sockets do
    sock_service_name "netbios-ssn"
  end
  sockets[0] do
    sock_service_name "netbios"
    bonjour ['smb']
  end

# => Result: Exception error. because implicit "Listeners" key is
declared twice.




:)


dreamcat4
dreamcat4 at gmail.com

On Wed, Mar 3, 2010 at 11:45 AM, Quinn <eskimo1 at apple.com> wrote:
> At 20:19 +0000 2/3/10, dreamcat four wrote:
>>
>> Are all of these different possible structures interchangeable?
>
> It depends on your perspective.  From the perspective of launchd, it doesn't
> care which format you use.  From the perspective of a launchd daemon
> developer, each format offers unique advantages.
>
> o If the sockets perform distinct functions, the dictionary of dictionaries
> approach lets the launchd daemon easily determine which socket is which.
>
> o If the sockets perform similar functions, Tthe dictionary of array of
> dictionaries approach makes that obvious.
>
> If you're writing a tool to manipulate launchd plists, I'd recommend that
> you work hard to preserve this distinction.  A launchd daemon that expects
> its checkin results to be in one one format is probably going to fail if
> they are in the other.
>
> S+E
> --
> Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev
>


More information about the launchd-dev mailing list