Java 和 C# 之间的通信

发布于 2024-08-10 11:36:00 字数 253 浏览 5 评论 0原文

我发现有一个名为 GCT - Group Communication Toolkit 的 .Net 工具包,它是 JGroup 的 C# 版本。我想知道这个和JGroup是否可以连接在一起,使java和C#客户端相互通信。 如果不是,那么让 java 程序和 C# 程序进行通信的最佳选择是什么? 我遇到的另一种选择是 XMPP 实施。 我需要在同一台计算机上运行的两个程序之间非常快速地传递消息。主要要求是,当触发某些特定事件时,该程序中的任何一个都将向另一个程序发送消息。 欢迎任何想法。

I found out that there is a .Net toolkit called GCT - Group Communication Toolkit that is the C# version of JGroup. I want to know whether this and JGroup can be connected together to make java and C# clients communicate with each other.
If not, what would be the best option to make a java program and a C# program communicate?
One other option I came across is XMPP implementation.
I require very fast message passing between those two programs that are running in the same computer. The main requirement is that either of this program would send a message to the other, when some particular events are triggered.
any ideas are welcome.

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

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

发布评论

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

评论(6

祁梦 2024-08-17 11:36:00

XMPP 不是您想要的。它设计用于在具有中央服务器的计算机之间传递消息。

我建议使用套接字在应用程序之间传递数据。请参阅 C# 中的 System.Net.Sockets.Socket 类和 Java 中的 java.net.Socket 类。

XMPP isn't what you want. It's designed for passing messages between computers with a central server.

I'd recommend using sockets to pass data between the apps. See the System.Net.Sockets.Socket class in C# and the java.net.Socket class in Java.

天荒地未老 2024-08-17 11:36:00

在我工作的地方,我们使用 ICE (http://www.zeroc.com/)。它让我们能够在 java 和 C# 之间编组二进制数据。这还不错。

Where I work we use ICE (http://www.zeroc.com/). It lets us marshal binary data between java and C#. It's not bad.

離殇 2024-08-17 11:36:00

Google 的 Protocol Buffers 可能是一个选择。它非常便携并且速度相当快。

Google's Protocol Buffers might be a option. It's very portable and quite fast.

近箐 2024-08-17 11:36:00

响应 OP 的“答案”...

将“服务器推送”映射到经典 RPC 模型(例如,由 CORBA、SOAP、ICE、RMI 等实现)的方法是翻转角色,以便您可以可以将其视为您的服务器在 RPC 中扮演客户端角色。该模式如下:

  1. 您的客户端调用您的服务器,传递回调对象的句柄。

  2. 服务器记住回调对象并返回。

  3. 客户端进入睡眠状态(或执行其他操作...)

随后,服务器想要推送一些数据。

  1. 服务器在回调对象上调用“push”RPC,传递数据。

  2. 客户端接收对回调对象的调用/请求,对数据执行某些操作,然后进行回复。

    客户端接收对回调对象的调用/请求

Responding to the OP's "answer" ...

The way to map "server push" onto the classical RPC model (e.g. as implemented by CORBA, SOAP, ICE, RMI, and so on) is to flip the role so that the thing you think of as your server fills the client role in the RPC. The pattern is like this:

  1. Your client makes a call to your server, passing the handle for a callback object.

  2. The server remembers the callback object and returns.

  3. The client goes to sleep (or does something else ...)

Later on, the server wants to push some data.

  1. The server invokes the "push" RPC on the callback object, passing the data.

  2. The client receives the call/request on the callback object, does something with the data, and replies.

睫毛溺水了 2024-08-17 11:36:00

如果我正在这样做,并且需要低延迟,我可能会考虑内存映射文件或管道。其中任何一个都需要一些 JNI 和 p/invoke 编程。

If I were doing this, and needed low-latency, I might consider a memory-mapped file, or a pipe. Either of these would require some JNI and p/invoke programming.

说好的呢 2024-08-17 11:36:00

如果性能很重要,请查看科学计算中使用的内容。科学家们在企业中也遇到了同样的问题,需要以更广泛的语言和平台连接客户端和服务器等等。也许这个名为 Babel 的组件绑定工具会在其原始领域之外发挥作用?接口由 SIDL 描述(如 CORBA 中的 IDL),但我不知道 C# 是否已涵盖。 https://computation.llnl.gov/casc/components/babel.html

If performance is important, see what's used in scientific computing. Scientists have the same sort of problems seen in enterprises, needing to connect clients and servers and all that, in an even wider range of languages and platforms. Perhaps this component tie-together tool called Babel would be useful beyond its original domain? Interfaces are described by SIDL (like IDL in CORBA) but I don't know if C# is covered yet. https://computation.llnl.gov/casc/components/babel.html

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