之间的C#应用​​程序和非托管C ++应用程序间的通信 [英] Interprocess Communication Between C# application and unmanaged C++ application

查看:138
本文介绍了之间的C#应用​​程序和非托管C ++应用程序间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个窗口服务,第一个用C#编写,第二写在
非托管C ++,我想知道我该怎么做双向的进程间通信。


< DIV CLASS =h2_lin>解决方案

如果进程间通信总是要在同一台机器上完成,命名管道是去,因为他们比其他选择更快速的方式。



然而,如果连这个通信可能会在某个时候跨计算机出现丝毫的机会,去与插座的方式。对于C ++,您将需要winsock2.h头文件。在C#中,使用 System.Net。套接字 命名空间。



它已经一段时间,因为我已经做非托管C ++,但我的记忆是,你必须如果您创建的C ++服务器侧写更少的C ++代码,然后使用的 的TcpClient 在C#端类。


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.

解决方案

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.

这篇关于之间的C#应用​​程序和非托管C ++应用程序间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆