Tag: named pipes

以编程方式获取命名管道的系统名称

我正在使用WCF NetNamedPipeBinding编写进程间通信。 我的目标是让服务在“net.pipe:// localhost / service”运行,所以我运行最简单的主机: host = new ServiceHost(contract, new Uri[] { “net.pipe://localhost” }); host.AddServiceEndpoint(typeof (IContract), new NetNamedPipeBinding(), “service”); host.Open(); 根据http://blogs.msdn.com/b/rodneyviana/archive/2011/03/22/named-pipes-in-wcf-are-named-but-not-by-you-and-how-to- find-the-actual-windows-object-name.aspx该名称隐藏在系统生成的guid后面。 这就是问题所在。 是否有任何可能的方法来获取系统(guid)在我的程序中生成的名称,所以我可以获得像“\ Device \ NamedPipe \ GUID”这样的路径,就像在procexp中一样,所以它会更容易嗅探它? (除了在单独的进程中运行sys internals可执行文件并解析其输出?)

如何测试网管服务是否正在监听

如何以编程方式测试以查看特定的网络管道服务是否正在运行和监听,因此我没有得到“没有端点监听……”exception? 所以,例如,如果我有这个代码: Uri baseAddress = new Uri(“http://localhost/something”); var _ServiceHost = new ServiceHost(typeof(Automation), new Uri[] { baseAddress }); NetNamedPipeBinding nnpb = new NetNamedPipeBinding(); _ServiceHost.AddServiceEndpoint(typeof(IAutomation), nnpb, “ImListening”); _ServiceHost.Open(); 我希望从另一个应用程序与http://localhost/something/ImListening通信,但在我想确保正在监听之前我没有得到exception,或者是测试这个的唯一方法的exception?

命名管道创建中的所有实例繁忙exception

我有一个Windows服务,通过命名管道与gui应用程序通信。 因此,我有一个线程正在运行等待应用程序连接,如果我这样做,运行正常。 但是,如果线程正在创建命名管道流服务器的新实例,则已建立的连接会中断并且我将获得所有实例繁忙exception。 抛出exception的代码片段是这样的: class PipeStreamWriter : TextWriter { static NamedPipeServerStream _output = null; static StreamWriter _writer = null; static Thread myThread = null; public PipeStreamWriter() { if (myThread == null) { ThreadStart newThread = new ThreadStart(delegate{WaitForPipeClient();}); myThread = new Thread(newThread); myThread.Start(); } } public static void WaitForPipeClient() { Thread.Sleep(25000); while (true) { NamedPipeServerStream ps […]

NamedPipeServerStream / async可靠的断开连接问题

我们使用命名管道在C#.Net服务和本机C ++应用程序之间进行通信。 该服务创建一个消息模式管道,然后启动计时器。 m_pipeServer = new NamedPipeServerStream (“Cyber_Srv_EventPipe”, PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous, 4096, 4096, pipeSa); m_OutputQueue = new List(); 在计时器中,tick例程是主服务循环,如下所示: do { if (!m_bClientAttached) { try { m_pipeServer.WaitForConnection (); m_bClientAttached = true; } catch (InvalidOperationException invope) { sDebug = string.Format (“Pipe wait exception InvOpEx: {0}”, invope.Message); DebugMessage (sDebug); } } // the message-pumping part of […]

WCF HTTP和NamedPipe服务

我正在创建一个WCF服务,目前,它使用basicHttpBinding公开了许多合同。 但是,我现在想在同一台机器上本地使用该服务,并且netNamedPipeBinding在性能方面似乎更合适。 出于这个原因,我想使用命名管道和HTTP公开服务。 目前我正在使用以下配置执行此操作: 这看起来工作正常,但仔细观察后,端点仍然使用basicHttpBinding。 这有效,但我得到的印象是它产生了不必要的开销。 我是否需要为每个合约和每个绑定类型(即basicHttpBinding和netNamedPipeBinding)创建一个端点,或者我是否完全错误? (如果不清楚,我对WCF还不熟悉!)

COM端口与Virtual PC通信

我正在测试使用COM-Port的应用程序。 该应用程序在Virtual PC中运行。 我已经设置了Virtual PC设置,以便为COM1-Port使用命名管道\。\ pipe \ mypipe。 现在我正在尝试使用C#与此命名管道进行通信。 using (var pipe = new NamedPipeServerStream(@”\\.\pipe\mypipe”)) { pipe.WaitForConnection(); using (var reader = new StreamReader(pipe)) { // Do some communication here } } 程序正在WaitForConnection()等待,虽然Virtual PC正在运行,我正在尝试与COM-Port通信。 我也尝试了以下内容,因为我不确定是否必须在程序中创建命名管道,或者命名管道是由Virtual PC创建的。 var p = new NamedPipeClientStream(@”pipe\mypipe”); p.Connect(); 我在这做错了什么?

c#中使用命名管道的两个进程之间的双工操作

我试图使用命名管道在同一台机器上的服务器和客户端进程之间进行通信。 服务器向客户端发送消息,客户端对其执行某些操作并返回结果,服务器应该得到结果。 这是服务器的代码: using System; using System.IO; using System.IO.Pipes; class PipeServer { static void Main() { using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(“testpipe”, PipeDirection.InOut)) { Console.WriteLine(“NamedPipeServerStream object created.”); // Wait for a client to connect Console.Write(“Waiting for client connection…”); pipeServer.WaitForConnection(); Console.WriteLine(“Client connected.”); try { // Read user input and send that to the client process. using […]

命名管道性能问题

我正在使用命名管道进行C#和Delphi之间的程序间通信。 C#使用System.IO.Pipes包,而Delphi使用Libby’s pipes.pas 。 不幸的是,通信几乎都是高性能的:分析表明通信占整个运行时间的72%,其余的则用于计算。 我找到了一个可能占用资源的问题:如果我没有在Delphi中明确断开发送客户端的连接, C#根本就不会收到任何数据 。 delphi(发送) FClient1.Write(msg[1], Length(msg)); FClient1.FlushPipeBuffers; FClient1.WaitForReply(20); FClient1.Disconnect; // disconnect to signalize C# that the writing is finished FClient1.Connect; // connect again to prevent synchronization problems C#(接收) // Wait for a client to connect stc.pipeServer.WaitForConnection(); while (reconnect_attempts < MAX_RECONNECT_ATTEMPTS) // { string tmp = sr.ReadLine(); // if result is […]

NetNamedPipeBinding安全吗?

我想知道netNamedPipeBinding是否被认为是安全的: 一方面,NetNamedPipeBinding仅在传输层上实现安全性,并且它使用Microsoft不再推荐的NTLM( 源 )( 源 ) 另一方面,无法从远程计算机访问命名Pipie,并且无法窃听用于传输数据或向其写入数据的特定打开管道实例,除非可以获取特定实例的句柄关心。 这就是为什么我不知道如何考虑这个解决方案的安全性的原因。

使用NetNamedPipe的WCF多个应用程序

我试图在同一台机器上运行多个WCF服务托管应用程序。 我想在一个应用程序中运行多个应用程序 – 而不是多个服务。 var host = new ServiceHost(typeof(MyClass1), new Uri[] { new Uri(“net.pipe://localhost”) }); host.AddServiceEndpoint(typeof(ISomeInterface), new NetNamedPipeBinding(), “FOO”); host.Open(); 我为每个应用程序更改“FOO”,但仍无法启动多个服务。 猜猜它很简单,但我卡住了:( 问候