开发者

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

开发者 https://www.devze.com 2023-01-03 18:07 出处:网络
How 开发者_如何学Cto create NAMED-PIPE in .NET-4 in your C# application?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 communic

How 开发者_如何学Cto create NAMED-PIPE in .NET-4 in your C# application?


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(); 
    } 
  } 
}


The easiest way is using WCF:

var binding = new System.ServiceModel.NetNamedPipeBinding(System.ServiceModel.NetNamedPipeSecurityMode.None)

0

精彩评论

暂无评论...
验证码 换一张
取 消