English 中文(简体)
Mac OS X-Cocoa应用程序和运行在同一个盒子上的基于Java的应用程序(守护进程)之间的最佳“通信”方式是什么
原标题:Mac OS X - what s the best way of "communication" between an Cocoa app and a Java based app (daemon) running on the same box
  • 时间:2011-05-27 21:45:52
  •  标签:
  • cocoa
  • ipc

我在Cocoa上有一个用objective-c编写的应用程序,有一些UI。我正计划编写另一个Java应用程序,它可以在后台运行并自动启动(本质上是一个dameon)。然后,Cocoa应用程序将与Java应用程序“通信”,开始定期或按需执行一些任务。这可行吗?如果是这样的话,就编程复杂性而言,两者之间最好的沟通方式是什么?插座通过文件?命名管道?

最佳回答

这当然是可行的。有很多潜在的机制,但它们都归结为选择一些进程间通信机制。但是,为什么要将java应用程序作为守护程序呢?显而易见的是,你的Cocoa应用程序只运行Java应用程序。

如果由于某种原因——比如说java应用程序有很多持久状态,或者需要很长时间才能启动——那么最简单的方法可能是使用命名管道,a/k/a FIFO。创建FIFO后,您可以简单地从UI进程中对其进行写入,并将其作为文件从Java中读取。这还有一个额外的优点,即它提供了一个自然的事件队列(这就是它的用途,这就是为什么它被称为FIFO的原因)

问题回答

你如何定义“最佳”?最快?设置最简单?交易安全吗?

也许最简单的方法是让java应用程序在一个单独的线程上启动http或xmlrpc服务器。有很多客户端和服务器库可以提供帮助。作为一个附带的好处,它使java应用程序更容易测试,因为您可以在开发过程中使用curl等命令行工具来模拟可可应用程序。





相关问题
posix_ipc python package equivalent for Windows?

Inter process communication primitives (Semaphores, Shared Memory) in python on windows? posix_ipc works great on linux, anything similar for windows?

passing events from erlang to Clojure

I m looking for a way to pass events back and forth between Clojure and erlang. has someone done this before? how should I encode the (immutable) messages in a flaxable general way? Should IPC be ...

Sockets vs named pipes for local IPC on Windows?

Are there any reasons for favoring named pipes over sockets for local IPC (both using win-api), effectiveness-wize, resource-wize or otherwise, since both behave very much alike (and likely to be ...

transparent process creation for cocoa components

I have an application A which may or may not need to spawn an application B and will communicate with it using remote messaging (via NSConnections etc.). While i know how to do this if B is started ...

Linux Pipes as Input and Output

I would like to do the following inside a C program on a Linux os: Create a PIPE using a syscall (or 2) Execute a new process using exec() Connect the process s STDIN to to the previously created ...

Shared memory vs. Go channel communication

One of Go s slogans is Do not communicate by sharing memory; instead, share memory by communicating. I am wondering whether Go allows two different Go-compiled binaries running on the same machine to ...

IPC between Python and C#

I want to pass data between a Python and a C# application in Windows (I want the channel to be bi-directional) In fact I wanna pass a struct containing data about a network packet that I ve captured ...

热门标签