简体   繁体   中英

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#). What is the fastest way to do this?

PS: OS: 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.

They work very well from native code (C++) as well as from C# via NamedPipeClientStream and NamedPipeServerStream .

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

All IPC mechanisms

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

My recommendation would be Sockets or RPC. I'm not familiar with pipes, but it seems to be a popular option too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM