[英]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 ++)以及通过NamedPipeClientStream和NamedPipeServerStream从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.
如果您需要速度,那么网络套接字可能是一个不错的选择。
如果它是有用的,如果这是进程间通信并不重要(如果你需要的功能可以形成一个使用或类似的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.