I have an app written in objective-c on Cocoa, having some UI. I am planning to write another Java app that could runs in the background and auto start (essentially a dameon). And then the Cocoa app will “communicate” with the Java app to start doing some tasks periodically or on demand. Is that doable? If so, what’ll be the best way of communication between the two in terms of programming complexities? Socket? via File? Named pipe?
Share
It’s certainly doable. There are a bunch of potential mechanisms, but they all come down to picking some interprocess communication mechanism. But why do you want the java app as a daemon? The sort of obvious thing is for your Cocoa app to just run the Java app.
If it turns out that for some reason — say the java app has a lot of persistent state, or takes a long time to start up — then the easiest method may be to use a named pipe, a/k/a a FIFO. Once you create the FIFO, you can simply write to it from the UI process and read it, as a file, from Java. This has the additional advantage that it provides a natural queue of events (which is what it’s for, that’s why it’s called a FIFO.)