Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interprocess Communication Between C# application and unmanaged C++ application

Tags:

c++

c#

ipc

I have two Windows services, the first one written in C# and the second written in unmanaged C++, I want to know how can I do two-way interprocess communication.

like image 386
netseng Avatar asked Feb 12 '09 03:02

netseng


1 Answers

If the interprocess communication is always going to be done on the same machine, named pipes is the way to go because they are faster than other options.

However, if there is even the slightest chance that this communication might occur across machine boundaries at some point, go with the socket approach. For C++, you'll need the winsock2.h header file. In C#, use the System.Net.Sockets namespace.

It's been a while since I've done unmanaged C++, but my recollection is that you'll have to write less C++ code if you create the server on the C++ side and then use the TcpClient class on the C# side.

like image 160
Matt Davis Avatar answered Nov 14 '22 23:11

Matt Davis