views:

353

answers:

1

I'm struggling to get a .NET (NOT a WCF) named pipe to communicate across the network. The MSDN documentation implies this is possible, nay trivial. But my code:

 using (NamedPipeClientStream pipeClient = new NamedPipeClientStream(servername, "myPipe", PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.Impersonation))

... works great when servername="localhost" and the pipe server is on the same box. But if it's another machine - regardless whether I make servername an IP address, DNS name, NetBIOS name, UNC path etc - means the pipe never connects. It doesn't actually fail, pipeClient.Connect() just sits there.

There's so many different and conflicting posts on various forums, blogs and sites about this. Can anyone set the record straight and tell me: how do I get a Named Pipe Client to connect from one C# application on one machine to a Named Pipe Server running on an another machine?

+1  A: 

Are you doing this at work? Is a corporate firewall or anti-virus program running? Check the windows event logs and any applications in your task notification icons area on your start bar for hints as to who is blocking this.

David Gladfelter
Specifically, verify that port 445 (used for named pipes) is open on the machine you are trying to connect to.
Peter Lillevold
Arghh. Can't believe I've been so daft. Just noticed that my dev-environment VM had mysteriously jumped onto a different DHCP range and didn't have proper comms with the target server. Thanks for the reply, I'm off to slap myself around the head now.
Kenny Anderson