Skip navigation.
 
mlusing Cocoa DO without vending an object
FROM : Tjark Derlien
DATE : Mon Dec 20 23:37:22 2004

This questions may have been asked several times, but I haven't found
an answer anywhere (yet).

My Cocoa app launches a foundation tool which is the app's "private
tool" to do privileged operations. The app and the tool can initially
communicate through a bidirectional FILE stream with each other.
I would like to use Cocoa's distributed objects system to call
functions on it - but without vending an object or it's connection
ports with NSConnection's registerName, NSMessagePortNameServer or
NSMachBootstrapServer due to security concerns (the tool runs with root
privileges).

As far as I understand Cocoa's DO, the tool and the app have to do the
following:

tool (e.g. in "main" function):
1. create send and receive ports (NSPort objects) for it's process
2. create a NSConnection object "serverConnection" using the two ports:
    NSConnection* serverConnection = [NSConnectionn
connectionWithReceivePort: receivePort sendPort: sendPort];
3. [serverConnection setRootObject: serverObject] (assuming
"serverObject" is the object to be made available)
4. send some information about these ports back to app (through the
FILE* channel), so the app can create it's own NSPort objects with this
information
4. let "serverConnection" receive requests:
    [serverConnection addRunLoop: [NSRunLoop currentRunloop]];

application (after launching the tool):
1. receive information about the tool's send and receive ports (through
the FILE* channel)
2. create send and receive ports (NSPort objects) using this information
3. create a NSConnection object "clientConnection" using these ports
4. get a proxy for the server object: id serverObject =
[clientConnection rootProxy]
5. work with "serverObject"

If this strategy isn't totally wrong I have these concrete questions:
- What kind of ports should I use?
- How do I create them?
- What information must the tool send to the app so the app can connect
to the server object? (some kind of "NSStreamPort" would be useful,
right?)

Thanks for any help,
Tjark Derlien

Related mailsAuthorDate
mlusing Cocoa DO without vending an object Tjark Derlien Dec 20, 23:37
mlRe: using Cocoa DO without vending an object Stéphane Corthésy Dec 21, 09:43
mlRe: using Cocoa DO without vending an object Timothy J.Wood Dec 21, 19:58