[launchd-dev] UNIX SOCKET problem

Gian Luca Gaiba g.gaiba at performer.it
Wed Sep 28 00:55:42 PDT 2011


On Sep 27, 2011, at September 27, 201111:30 AM, Quinn The Eskimo! wrote:

> UNIX domain sockets don't need a port.  In a TCP connection, the destination address consists of the IP address (the machine on which the server is running) and a port (to identify the service within that machine).  For a UNIX domain socket the server is always running on the local machine, so you only need to identify the service on the machine, which is what the path does.

Yes, I read about that, and that's why I didn't configure a port... 

> 
> As to your original problem, I'm not sure what's going on.  The best solution to this problem is to have launchd managing your listening socket for you.  I don't know of a simple sample that shows this for UNIX domain sockets, but the SampleD sample code shows it for TCP sockets.
> 
> <http://developer.apple.com/library/mac/#samplecode/SampleD/>
> 
> You can also look at BetterAuthorizationSample, which is rather complex but does show the UNIX domain sockets side of things.
> 
> <http://developer.apple.com/library/mac/#samplecode/BetterAuthorizationSample/>
> 
> If you must create your own UNIX domain socket (which, again, isn't what I recommend), you can look at the CFLocalServer sample code, which shows how to do that.
> 
> <http://developer.apple.com/library/mac/samplecode/CFLocalServer/>

I have the socket managed by launchd but the problem is in testing...
I have two constuctors for the socket
one if it's managed by launchd
and one when I run the procedure in testing mode (I.e. from xCode)
that compose a UNIX socket like in CFLocalServer...
I think I have done anything correctly 
but the socket is not reusable...
this is not a "real" problem but I'd like to understand why this thing happen...
The only thing I think I differ
is the socket path
that isn't in the standard /var directory
but in /Users/myuser directory...

this could be a problem?

thanks and regards
Gian Luca


More information about the launchd-dev mailing list