Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sivaprakash

macrumors member
Original poster
Mar 10, 2011
52
0
Chennai, India
Hi

What are the different IPC mechanisms available in Objective-C for Mac. I am planning to use Queue mechanism to achieve this.

1. Client application can post a request into Queue

2. Daemon (Service) which is running in the same machine looks for new message in queue

3. If there is any message in the queue then the service can take it and process

Document :-

http://bit.ly/dHMKra


Is it possible with Queue.

Thanks
Siva
 
Last edited:

sivaprakash

macrumors member
Original poster
Mar 10, 2011
52
0
Chennai, India
Will this work out ? for me to exchange the data between Client and Service (same machine)

http://developer.apple.com/library/...ction.html#//apple_ref/doc/uid/TP40008100-SW1

Or What could be the best way to exchange data between Client Application and Service? Can you please pass some tutorial or sample?

Note:- Service is similar to Windows Service, which should start itself when the system boots up and there wont be any GUI. Only entry points will be there in which Client application will communicate.

Please pass some light.

Thanks
Siva
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
I don't think Pasteboards are what you want either. These are used user initiated copy'n'paste like operations.

Note that what windows calls a service is nothing like what Mac OS X calls a Service. Under Mac OS X, and Unix in general, you want to be using and looking for the term daemon.

It sounds like you want to do remote messaging. Try Distributed Objects.

But perhaps this is overkills. Perhaps you could just use a file system socket.
 

sivaprakash

macrumors member
Original poster
Mar 10, 2011
52
0
Chennai, India
Can you please give me some tutorial which explains step-by-step procedures to write and register service also pass data from client application?

Thanks
Siva
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
Depending on what you want to do, you could implement a service, as would appear in the Services submenu of the application menu as described in this Doc. Such a service can be invoked either by the user, from the menu, or by the program itself (read the section). If you do not want the service to be directly accessible to the user, this might not be the strategy you want to employ.

Alternately, you could implement and publish a Bonjour service. These, IIRC, communicate through pipes (NSPipe — pipes are one-way, so you would need two for back and forth communication) and you could just create a unique type of service that might be application-specific. Bonjour services are node-agnostic: they can live on any machine on the network and be accessed from any machine on the network. If security might be a concern, you would have to set up the service provider to check that the client is ok (e.g., not requesting information or action that should be prohibited to it).
 

sivaprakash

macrumors member
Original poster
Mar 10, 2011
52
0
Chennai, India
Hi

Thanks for your info... and looks like NSPipe would solve the purpose.

Let's say I am writing a Damon (Service) and that will keep on running in my machine. Since NSPipe provides one way communication I have to have two service to transfer data back and forth.

Can you please let me know


- I would like to know one thing, there should be some way to register my service right?

- How to write Damon threads ?

Thanks
Siva
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
Depending on what you need to do, one possibility would be to use a NSDistantObject. This would allow you to communicate directly between two applications by passing messages to an object. What that would involve is:

- Create a class that both server app and client(s) are aware of (this might involve building a framework for the class)

- Write a server app that "vends" the object to make it available to the client app

- The client app will look for the vended object and establish a proxy object that it can use to communicate directly via Objective-C method invocations (NSInvocation). Methods can be synchronous (blocking the sending thread) or not. The distant object can also return values to the sender (if the invocation is synchronous).

This is pretty elaborate, but mostly a lot of busywork to implement. You could just use the vended object as a means for the client to locate the server daemon and obtain a pair of pipes – not really sure, but I suspect passing methods to distant objects is probably not terribly efficient and should be used sparingly.

Distant Objects Documentation
 

sivaprakash

macrumors member
Original poster
Mar 10, 2011
52
0
Chennai, India
Thanks !!

1. Can I make this as an Asynchronous Call ?

2. Any time Server application can talk to client application once the client app Vends the object to communicate ?

Thanks
Siva
 

pilotError

macrumors 68020
Apr 12, 2006
2,237
4
Long Island
If you need bi-directional messaging, it's so much easier to create a socket and communicate that way. Then it won't matter if your clients are on the same node or not.

If you want to get fancy, communicate through shared memory.

Here's a little powerpoint tutorial from University of Chicago

The site I posted above has plenty of IPC tutorials for you to look at and try.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.