Inter Process Communication

Discussion in 'Mac Programming' started by sivaprakash, Mar 16, 2011.

  1. sivaprakash, Mar 16, 2011
    Last edited: Mar 16, 2011

    sivaprakash macrumors member

    Joined:
    Mar 10, 2011
    Location:
    Chennai, India
    #1
    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
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
  3. sivaprakash thread starter macrumors member

    Joined:
    Mar 10, 2011
    Location:
    Chennai, India
    #3
    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
     
  4. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #4
    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.
     
  5. sivaprakash thread starter macrumors member

    Joined:
    Mar 10, 2011
    Location:
    Chennai, India
    #6
    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
     
  6. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #7
    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).
     
  7. pilotError macrumors 68020

    pilotError

    Joined:
    Apr 12, 2006
    Location:
    Long Island
    #8
    You should be able to search for any System V IPC Tutorial out on the web.

    A quick search came up with this site:

    http://www.academictutorials.com/ipc/ipc-system-v-ipc.asp

    IPC is pretty standard across the *nix variants.
     
  8. sivaprakash thread starter macrumors member

    Joined:
    Mar 10, 2011
    Location:
    Chennai, India
    #9
    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
     
  9. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #10
    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
     
  10. sivaprakash thread starter macrumors member

    Joined:
    Mar 10, 2011
    Location:
    Chennai, India
    #11
    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
     
  11. pilotError macrumors 68020

    pilotError

    Joined:
    Apr 12, 2006
    Location:
    Long Island
    #12
    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.
     

Share This Page