Fabio Vinicius Binder
Fabio Vinicius Binder

Reputation: 13214

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?

P.S.: OS: Windows XP

Upvotes: 2

Views: 3375

Answers (7)

cchampion
cchampion

Reputation: 7921

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

Upvotes: 1

Reed Copsey
Reed Copsey

Reputation: 564433

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.

Upvotes: 9

Marcin
Marcin

Reputation: 12590

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

Upvotes: 0

moonshadow
moonshadow

Reputation: 89085

Check out this article for a run-down of the available options. Your best bet is probably a pipe.

Upvotes: 2

antik
antik

Reputation: 5330

Just in case it's helpful, if it's not critical that this be interprocess communication (if the functionality you require out of one can be shaped into a DLL which both use or similar) you can use the Common Language Runtime for interoperability.

Upvotes: 0

Dima
Dima

Reputation: 39389

Using files would be the simplest way. If you need the speed, then network sockets may be a good option.

Upvotes: 1

Jonas Elfström
Jonas Elfström

Reputation: 31428

Shared memory would be the fastest but named pipes are pretty fast too and much easier to use.

Upvotes: 2

Related Questions