简体   繁体   English

同一台机器上的两个程序相互通信的最佳方法是什么

[英]What is the best way for two programs on the same machine to communicate with each other

I need to pass some data (integers) from one (C++) program to another (C#). 我需要将一些数据(整数)从一个(C ++)程序传递到另一个(C#)。 What is the fastest way to do this? 最快的方法是什么?

PS: OS: Windows XP PS:操作系统:Windows XP

My personal preference for this, given that you're using C++ and C# both, and it's on the same system, would be to use Pipes. 我个人对此的偏好,因为你使用的是C ++和C#,而且它们在同一个系统上,就是使用Pipes。

They work very well from native code (C++) as well as from C# via NamedPipeClientStream and NamedPipeServerStream . 它们通过本机代码(C ++)以及通过NamedPipeClientStreamNamedPipeServerStream从C#运行良好。

However, there are other options for Interprocess Communication , any of which would work. 但是, 进程间通信还有其他选项,其中任何一个都可以使用。

共享内存将是最快的,但命名管道也非常快,也更容易使用。

Check out this article for a run-down of the available options. 查看本文以了解可用选项的细分。 Your best bet is probably a pipe . 你最好的选择可能是一个管道

Using files would be the simplest way. 使用文件是最简单的方法。 If you need the speed, then network sockets may be a good option. 如果您需要速度,那么网络套接字可能是一个不错的选择。

mailslots can be used if you're communication is one-way and your messages are small. 如果您的通信是单向的并且您的消息很小,则可以使用邮件槽。 Otherwise I'd recommend using named pipes (as others have recommended). 否则我建议使用命名管道(正如其他人推荐的那样)。

here's something on mailslots 这是mailslots上的东西

All IPC mechanisms 所有IPC机制

如果它是有用的,如果这是进程间通信并不重要(如果你需要的功能可以形成一个使用或类似的DLL),你可以使用公共语言运行时进行互操作。

My recommendation would be Sockets or RPC. 我的建议是套接字或RPC。 I'm not familiar with pipes, but it seems to be a popular option too. 我不熟悉管道,但它似乎也是一个受欢迎的选择。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 让多个 .NET 应用程序相互通信的最佳方式 - Best way to let multiple .NET apps communicate with each other 什么WCF绑定可用于在同一台计算机上以不同特权在两个进程之间进行通信? - What WCF binding to use to communicate between two processes with different privileges on the same machine? 两个单独的 C# .Net 应用程序在同一台计算机上相互通信的最简单方法是什么 - What is the easiest way for two separate C# .Net apps to talk to each other on the same computer 在Windows中对程序进行基准测试的最佳方法是什么? - What's the best way to benchmark programs in Windows? C#:确保两个函数(2 个不同的类)永远不会相互独立调用的最佳方法是什么? - C#: What's the best way to ensure that two functions (2 different classes) never get called independently of each other? 每个项目用相同的图标绑定ListView(WPF)的最佳方法是什么 - what is the best way to bind ListView (WPF) with same icon for each item 让 2 个类在 C# 中相互通信的最佳方法 - Best aproach to let 2 classes communicate with each other in C# 处理这两个依赖于另一个的异步方法的最佳方法是什么? - What is the best way to handle this two async methods that one dependent on the other? 跨程序发送自定义ACS声明的最佳方法是什么? - What is the best way to send custom ACS Claims across programs? 在公共API中传达字符串参数的目的的最佳方法是什么? - What's the best way to communicate the purpose of a string parameter in a public API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM