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

℡╲_俬逩灬. 提交于 2019-12-06 05:23:26

问题


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


回答1:


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



回答2:


The easiest way is using WCF:

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



来源:https://stackoverflow.com/questions/3045304/how-to-create-named-pipe-in-net-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!