问题
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