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

前端 未结 8 2336
感动是毒
感动是毒 2021-01-05 15:20

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.

8条回答
  •  旧时难觅i
    2021-01-05 15:37

    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.

提交回复
热议问题