So I have a appA in C++ and it creates a namedpipe to receive communication. the name of the namedpipe is “\\.\pipe\apppipe” I also had another appB also written in C++ which connected to appA using the same named pipe. Easy.
Now moving up in the world :), appC comes along built with C# on the .NEt Framework 4.X and intends to connect to the same named pipe appA creates (appB is to be decomissioned). However, I find that the NamedPipeClientStream object doesn’t seem to be able to connect with appA’s namedpipe. I thought a namedpipe was a namedpipe and I didn’t have to care how it’s connected to.
This is appC’s way of trying to connect that’s failing…
NamedPipeClientStream pipeClient = new NamedPipeClientStream("\\\\.\\pipe\\apppipe");
pipeClient.Connect(5000);//5 second timeout
Does it have to do with the name? How should I represent this now on the C# side to connect to the same pipe?
thanks
EDIT:
appA’s pipe creation code is just
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\apppipe");
pipeHandle = CreateNamedPipe(
lpszPipename,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
BUFSIZE,
BUFSIZE,
0,
NULL);
if(pipeHandle == INVALID_HANDLE_VALUE)
{
acutPrintf(L"\n Problem creating pipe");
return;
}
is your friend!
you may also need to send in/out options (but probably not), more details check MSDN: How to: Use Named Pipes to Communicate Between Processes over a Network