Professional Web Applications Themes

Inter Process Communication in OS X - Mac Programming

Hi everybody, I'm writing a daemon on Panther which should be able to send events to local clients. Since the number of clients is unknown I'm searching for the right mechanism. On Windows I'm using Events , on Mac I found the AppleEvents, but I'm not sure whether this will work with daemons (there is an older thread stating it doesn't, even if Apple provides LowLevel dunctions for daemons). So my question is, whether I should go on and try the AE, or other methods (posix msg queues seem to be not available). Any hints or experiences? Thanks in advance! ...

  1. #1

    Default Inter Process Communication in OS X

    Hi everybody,

    I'm writing a daemon on Panther which should be able to send events to
    local clients. Since the number of clients is unknown I'm searching for
    the right mechanism. On Windows I'm using Events , on Mac I found the
    AppleEvents, but I'm not sure whether this will work with daemons (there
    is an older thread stating it doesn't, even if Apple provides LowLevel
    dunctions for daemons).

    So my question is, whether I should go on and try the AE, or other
    methods (posix msg queues seem to be not available).

    Any hints or experiences?


    Thanks in advance!

    Juergen








    Juergen Guest

  2. #2

    Default Re: Inter Process Communication in OS X

    In article <bv35ev$v9a$toplink-plannet.de>,
    Juergen Ockert <de> wrote:
     

    That depends what you mean by 'daemon'. The term is overloaded
    unfortunately. Do you mean daemno in the unix sense or the OS 9 sense?
    Sean Guest

  3. #3

    Default Re: Inter Process Communication in OS X

     

    Mac OS X daemon, which means it should be started during machine boot
    without a user necessarily logged in.

    Juergen Guest

  4. #4

    Default Re: Inter Process Communication in OS X

    In article <bv3l0o$3k8$toplink-plannet.de>,
    Juergen Ockert <de> wrote:
     

    In this case you will not be able to use several frameworks, including
    Carbon.framework. I believe you can use some subset of AppleEvents
    however, maybe someone else has tried...
    Sean Guest

  5. #5

    Default Re: Inter Process Communication in OS X

    In article <bv35ev$v9a$toplink-plannet.de>,
    Juergen Ockert <de> wrote:
     

    For regular applications, AppleEvents are the way to go. For a daemon, I
    suggest looking at CFMessagePort (or even low level MACH messages).

    It's *possible* to do AppleEvents in a daemon, but very painful & ugly.
    Using AppleEvents means it needs to connect to the window manager and
    will die when the user logs out (there was an ugly hack for that in
    Jaguar, which doesn't work in Panther).

    --
    Mike Cohen - mike3k <at> onepost <dot> net
    Personal: http://www.mc-development.com/
    Mac News: http://www.macmegasite.com/
    Mike Guest

  6. #6

    Default Re: Inter Process Communication in OS X

    In article <aei.ca>,
    Sean McBride <org> wrote:
     
    >
    > In this case you will not be able to use several frameworks, including
    > Carbon.framework. I believe you can use some subset of AppleEvents
    > however, maybe someone else has tried...[/ref]

    I ended up using CFMessagePort. It's fairly easy and doesn't depend on
    Carbon.framework.

    --
    Mike Cohen - mike3k <at> onepost <dot> net
    Personal: http://www.mc-development.com/
    Mac News: http://www.macmegasite.com/
    Mike Guest

  7. #7

    Default Re: Inter Process Communication in OS X

    > I ended up using CFMessagePort. It's fairly easy and doesn't depend on 

    I just build a simple test using CFMessagePort, but
    CFMessagePortCreateRemote() always return false, if invoked from another
    process.

    If the function is called in the same app after
    CFMessagePortCreateLocal() and CFRunLoopAddSource() it works.

    not what I expected...


    regards

    Juergen


    Juergen Guest

  8. #8

    Default Re: Inter Process Communication in OS X

    On Wed, 28 Jan 2004, Juergen Ockert wrote:
     
    >
    > I just build a simple test using CFMessagePort, but
    > CFMessagePortCreateRemote() always return false, if invoked from another
    > process.
    >
    > If the function is called in the same app after
    > CFMessagePortCreateLocal() and CFRunLoopAddSource() it works.[/ref]

    Weird, i currently use CFMessagePort to communicate between a Cocoa app
    (that displays an NSStatusItem) and my main app, written in Carbon with no
    problems what so ever (although it may that one user's process can't
    access another user's message ports or something like that).

    Fred
     

    Frederick Guest

  9. #9

    Default Re: Inter Process Communication in OS X

    In article <bv8rgd$ksi$toplink-plannet.de>,
    Juergen Ockert <de> wrote:
     
    >
    > I just build a simple test using CFMessagePort, but
    > CFMessagePortCreateRemote() always return false, if invoked from another
    > process.
    >
    > If the function is called in the same app after
    > CFMessagePortCreateLocal() and CFRunLoopAddSource() it works.
    >
    > not what I expected...
    >[/ref]

    Make sure the application which called CFMessagePortCreateLocal is
    running before the other app calls CFMessagePortCreateRemote and both
    use the same name. That's how I'm signaling between two daemons.

    --
    Mike Cohen - mike3k <at> onepost <dot> net
    Personal: http://www.mc-development.com/
    Mac News: http://www.macmegasite.com/
    Mike Guest

  10. #10

    Default Re: Inter Process Communication in OS X

    Problem solved!

    I still do not understand why, but my test application runs fine in the
    terminal window of the SAME computer!

    If logged in remote (via ssh, like i do my simple development stuff) it
    DOES NOT WORK :-(


    regards

    Juergen


    Juergen Guest

  11. #11

    Default Re: Inter Process Communication in OS X

    In article <bvlo5g$6fl$toplink-plannet.de>,
    Juergen Ockert <de> wrote:
     

    It's a bootstrap server issue. Your daemons and applications aren't on
    the same bootstrap server. Your app can see your daemon but not
    vice-versa.

    This is covered somewhat in:

    http://developer.apple.com/doentation/MacOSX/Conceptual/BPMultipleUser
    s/index.html

    {I went through this a while back and that's the answer I got back from
    the Carbon List}

    You'll want to use a mach port (Mach RPC). When your app launches it
    creates a mach port and sends your daemon a send right for that port.

    Email me for some great sample code that I was sent (DaemonLover).

    Cheers,
    H.

    {hpetschauer AT atimi DOT com}

    --
    To reply via email, replace "LastNameHere" with my last name.
    Herb Guest

Similar Threads

  1. Detect a stale mutex file for inter-process synch
    By Lu in forum UNIX Programming
    Replies: 4
    Last Post: November 25th, 07:43 PM
  2. inter-level controlling
    By duderOfHunka webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 3
    Last Post: August 27th, 03:25 PM
  3. remote inter-program communication?
    By Bing Du Test in forum Linux / Unix Administration
    Replies: 4
    Last Post: August 11th, 05:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139