C# 3.5 - Connecting named pipe across network

12,811

Solution 1

It is not possible to used named pipes between machines.

"The WCF-NetNamedPipe adapter provides cross-process communication on the same computer"

http://msdn.microsoft.com/en-us/library/bb226493.aspx

Solution 2

You need to set permissions on the NamedPipeServerStream so that the client will have permissions to access the pipe.

I would look at the SetAccessControl method of your NamedPipeServerStream.

Share:
12,811
Anton
Author by

Anton

Updated on June 04, 2022

Comments

  • Anton
    Anton almost 2 years

    What is the correct way to setup a named pipe in C# across a network?

    Currently I have two machines, 'client' and 'server'.

    Server sets up its pipe in the following manner:

    NamedPipeServerStream pipeServer = new NamedPipeServerStream(
        "pipe",
        PipeDirection.InOut,
        10,
        PipeTransmissionMode.Byte,
        PipeOptions.None)
    pipeServer.WaitForConnection();
    //... Read some data from the pipe
    

    The client sets up its connection in the following manner:

    NamedPipeClientStream pipeClient = new NamedPipeClientStream(
        "server",
        "pipe",
        PipeDirection.InOut);
    pipeClient.Connect(); //This line throws an exception
    //... Write some data to the pipe
    

    The 'server' machine can be accessed on the network by going to "\\server".

    Whenever I run the program, I get a System.UnauthorizedAccessException that says "Access to the path is denied." The code works fine when I run the server and client on my local machine and attempt to connect to "." with the client.

  • weismat
    weismat about 14 years
    This is Bizz Server, not Windows doc. msdn.microsoft.com/en-us/library/aa365590(VS.85).aspx states that it should work!
  • Robert MacLean
    Robert MacLean almost 14 years
    That may be a WCF limitation. Named pipes in Windows (like the one the person is asking about) can work across networks. From: msdn.microsoft.com/en-us/library/… "Named pipes can be used for interprocess communication locally or over a network" There are some limitations - Local lans only (so the moment you hit a router it stops) - Older versions of Windows (like 2000) limit to 10 connections - Anonymous pipes are single machine only