Named pipes: C# server, C++ client

陌路散爱 提交于 2019-12-24 01:25:57

问题


I wrote 2 pairs of named pipe client/server programs: 1st pair in C# (.NET 4) 2nd pair in C++ (un-managed)

All 4 test programs use the same pipe name \\.\pipe\mypipe

The C# pair work fine with each other - I send a message from the client and it is received by the server. The C++ pair work also fine with each other.

But... when I try to run the C# client with the C++ server, or the C++ client with the C# server - then it doesn't work. The client is unable to connect to the server.

Is there something preventing the C++ client from working with the .NET server? Should it work?

Thank you.


回答1:


NamedPipeClientStream and NamedPipeServerStream prefix "\\.\pipe\" to the name automatically.

C++ client code:

hPipe = CreateFile("\\\\.\\pipe\\mypipe", ...)

corresponding C# server code:

var pipe = new NamedPipeServerStream("mypipe", ...)


来源:https://stackoverflow.com/questions/35430705/named-pipes-c-sharp-server-c-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!