在 Java 应用程序和基于 C# 的插件之间建立 IPC 链接

发布于 2024-08-04 22:11:10 字数 448 浏览 3 评论 0原文

我们有一个 Java 应用程序,以及许多用于其他应用程序(例如 Excel)的基于 C# 的插件,可以与主应用程序进行通信。通信层使用 Java 端的 Apache MINA 和 .NET 插件的 xsd 来实现。通常,事物在同一台 (Windows) 计算机上运行,​​但最好不要假设(例如,允许主应用程序在 Mac 上运行并能够与不同计算机上的 Excel 进行通信)。

无论主应用程序还是插件先启动,通信都必须正常工作。我的问题是如何最好地建立链接?目前,我们的主要 Java 应用程序监听一个端口,插件不断轮询该端口的可用性。这显然是浪费且不雅的。但它有效。

另一种方法是让每个插件侦听自己的端口,当应用程序启动时,它会向每个已知端口(在本地主机上)发送一条“Hello”消息,然后让插件在该点建立链接。

我也看过一些多播,但不太了解。当然,同一子网上可能有多个用户都在使用该应用程序。

还有其他想法或想法吗?

We have a Java app, as well as a number of C#-based plugins for other apps (e.g. Excel) that can communicate with the main app. The communications layer is implemented using Apache MINA on the Java side and xsd for the .NET plugins. Typically things run on the same (Windows) machine, though it would be better not to assume that (e.g., allow the main app to run on a Mac and be able to communicate with Excel on a different machine).

The communication has to work regardless of whether the main app or the plugin(s) start up first. My question is how best to establish the link? Currently, our main Java app listens on a port that the plugins constantly poll for availability. This is obviously wasteful and inelegant. But it works.

An alternative would be to have each plugin listening on its own port, and when the app starts up it sends a "Hello" kind of message to each known port (on localhost), and then have the plugins establish the link at that point.

I've also looked a bit at multicast, but don't really know much about it. And of course, there could be multiple users on the same subnet all using the app.

Any other ideas or thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪菊怪哟 2024-08-11 22:11:10

您不应该担心连接到服务器的浪费尝试 - 这不是资源密集型操作,并且插件需要连接才能工作。似乎没有任何真正的动机去使用与您已经在做的传统客户端/服务器方法不同的任何东西。

You should not be concerned with wasted attempts to connect to the server - it is not a resource intensive operation and the plugin requires the connection to work. There does not seems to be any real motivation to use anything different from a traditional client/server approach which you already are doing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文