C# 应用程序与 C++ 中的其他应用程序之间的 IPC;和VB.Net

发布于 2024-11-06 12:34:01 字数 381 浏览 8 评论 0原文

我有一个 C# 服务器应用程序,它需要与另外 3 个客户端应用程序通信并控制:一个使用 C#,一个使用 C++,一个使用 VB.Net。它们都是 Windows 窗体应用程序。他们基本上需要交换一些字符串和数字,而不是负载很重。在 C# 和那些不同语言之间进行 IPC 的最佳方法是什么?请注意,客户端不会相互通信,它们只与服务器通信。

C# 需要与 C++ 对话,所以我猜 WCF 不好,因为 WCF 只能在两个 .Net 应用程序之间工作?

我可以在所有这些语言中方便地使用命名管道吗:C#、C++ 和 VB.Net?

我还想知道将来是否必须添加 VB6、VBScript 和 PowerShell 脚本作为客户端,适用于所有这 6 种语言的最佳 IPC 选项是什么?我仍然可以使用命名管道吗?

I have a C# server application and it needs to talk to and control another 3 client applications: one in C#, one in C++ and one in VB.Net. All of them are Windows Form applications. They basically need to exchange some strings and numbers, not heavily loaded. What is the best way to do IPC between C# and those different languages? Note that clients don't talk to each other, they only talk to the server.

C# needs to talk to C++ so I guess WCF isn't good, as WCF only works between two .Net applications?

Can I use named pipes conveniently in all these languages: C#, C++ and VB.Net?

I also want to know if in the future I have to add VB6, VBScript and PowerShell scripts as clients, what would be the best IPC option that works for all these 6 languages? Will I still be able to use named pipes?

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

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

发布评论

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

评论(3

紫南 2024-11-13 12:34:01

实际上,配置为通过 HTTP 公开服务的 WCF 可能是您想要支持的语言列表的最佳选择。

如果您不喜欢 WCF,请考虑公开 HTTP REST 接口,即通过在 ASP.Net MVC 中编写服务器。

命名管道支持 - C#/VB.Net、C++ - 很好,VB6 - 我不知道,VBScript - 绝对不是开箱即用的,PowerShell - 是的,因为它可以使用 .Net 库。

Actually WCF configured to expose services via HTTP might be the best option for the list of languages you want to support.

If you don't like WCF consider exposing HTTP REST interfaces i.e. by writing server in ASP.Net MVC.

Named pipes support - C#/VB.Net, C++ - good, VB6 - I don't know, VBScript - definitely not out of the box, PowerShell - yes as it can use .Net libraries.

茶底世界 2024-11-13 12:34:01

对于您列出的语言来说,最快的解决方案是命名管道,更好的是内存映射文件。两者都在 .NET 4.0 和非托管 C++ 中实现。

我建议查看内存映射文件。创建一个文件和一个关联的视图作为单生产者、多消费者、单向通道是相对简单的。例如,您可以使用该区域的前 4 个字节来存储最后写入的字节的更新值(以视图大小 - 4 字节为模),并使用 EventWaitHandle 来同步生产者/消费者访问。访问单独内存映射文件的两个通道将为您提供双工通道。

.NET(C# 和 VB.NET) 的链接
非托管 C++

然后,您可能希望研究协议缓冲区,将其作为序列化二进制数据的一种非常有效的方法。

0MQ 是 Linux 领域的一款优秀产品,但 Windows 版本有些精简,而且不支持 IPC。

The fastest solutions for the languages you listed are named pipes and, better still, memory mapped files. Both have implementations in .NET 4.0 and unmanaged C++.

I would recommend looking into memory mapped files. It's relatively straighforward to create a file and an associated view that serve as single-producer, multiple-consumer, unidirectional channel. You can use, say, the first 4 bytes of the area to store the updated value of the last byte written (modulo the view size - 4 bytes) and an EventWaitHandle to synchronise producer/consumer access. Two channels accessing separate memory mapped files will give you a duplex channel.

Links for .NET (C# and VB.NET) and
unmanaged C++.

You may then want to look into Protocol Buffers as a very efficient way to serialise your binary data.

0MQ is an excellent product in the Linux space but the Windows version is somewhat stripped-down, and among other things doesn't support IPC.

-柠檬树下少年和吉他 2024-11-13 12:34:01

您可以尝试不同的库,例如 OpenDDS、ZeroMQ 等。虽然Windows上的ZeroMQ还不支持IPC(但支持TCP)。

There are different libraries you can try such as OpenDDS, ZeroMQ and others. Though ZeroMQ on Windows does not support IPC yet (but supports TCP).

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