开发者

How can I most easily do IPC/RPC between Cocoa (client) and Java (server) running on the same host?

开发者 https://www.devze.com 2023-03-09 17:22 出处:网络
The Java end is a Bukkit plugin, so I don\'t have the freedom to build on a servlet engine like Tomcat. I don\'t need arbitrary access to any object; I just want to expose a subset of functionality av

The Java end is a Bukkit plugin, so I don't have the freedom to build on a servlet engine like Tomcat. I don't need arbitrary access to any object; I just want to expose a subset of functionality available to plugins to my wrapper application.

The Cocoa application, I am building from the ground up, so the restrictions are a bit looser. It's a wrapper for the server wit开发者_JAVA技巧h limited support for configuring certain plugins.

Something that can communicate over Unix sockets would be ideal since the processes are running on a single host, but TCP sockets are ok too. I'm not really picky. If I end up using TCP then I'll consider adding support for remote management, but it's not a priority. I don't want Unix sockets badly enough to bother with all the hoops I'd have to jump through to use them.


You might want to look at zeromq, it has bindings for Objective-C and Java, supports IPC, TCP, and more.


Java does not support UNIX sockets out-of-the box, but this question gives some alternatives.

Or you can just open a tcp socket on localhost to keep in the standard library.

There are a lot of solutions out there, but if you want to stay lean and mean, a simple socket is not too bad. All the boxed solutions are quite complex, as they need to deal with complex issues over the net. You will face only a small subset of these, so might be better of with a simple home-grown protocol over a socket.

Just make it asynchronous to avoid blocking.

0

精彩评论

暂无评论...
验证码 换一张
取 消