Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create NAMED-PIPE in .NET-4?

Tags:

c#

.net-4.0

How to create NAMED-PIPE in .NET-4 in your C# application?

like image 204
Rella Avatar asked Feb 26 '23 20:02

Rella


1 Answers

Here is a piece of code to create a Named Pipe client, it is lifted from an answer to a previous question I answered on communicating between C++ and C# using Named Pipes

using System; 
using System.Text; 
using System.IO; 
using System.IO.Pipes; 

namespace CSPipe 
{ 
  class Program 
  { 
    static void Main(string[] args) 
    { 
      NamedPipeClientStream pipe = new NamedPipeClientStream(".", "HyperPipe", PipeDirection.InOut); 
      pipe.Connect(); 
      using (StreamReader rdr = new StreamReader(pipe, Encoding.Unicode)) 
      { 
        System.Console.WriteLine(rdr.ReadToEnd()); 
      } 

      Console.ReadKey(); 
    } 
  } 
}
like image 86
Chris Taylor Avatar answered Mar 07 '23 02:03

Chris Taylor