Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Named pipes: C# server, C++ client

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.

like image 945
yaronkl Avatar asked Mar 27 '26 04:03

yaronkl


1 Answers

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", ...)
like image 106
alexm Avatar answered Mar 28 '26 18:03

alexm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!