c# - 什么是命名管道 (net.pipe) 限制?

标签 c# .net named-pipes net.pipe

我有一个循环运行的程序,每次迭代都在不同的线程中运行,我正在创建打开新服务主机的新进程:

ServiceHost _host = new ServiceHost(_service, new Uri("net.pipe://localhost/" + i_PipeName));
_host.AddServiceEndpoint(typeof(ICommandService), new NetNamedPipeBinding() { TransferMode = TransferMode.Buffered }, i_PipeName);
_host.Open();

在我的主程序中,我通过以下方式连接到打开的 .net 管道:

ICommandService ServiceProxy = ChannelFactory<ICommandService>.CreateChannel
(new NetNamedPipeBinding(), new EndpointAddress(@"net.pipe://localhost/" + i_PipeName" + @"/" + i_PipeName));

所以我的问题是,对于前 200 多个过程/迭代,它工作正常,我可以打开连接并传递消息,但后来开始出现错误:

There was no endpoint listening at net.pipe://localhost/pipea0360/pipea0360 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException if present, for more details.

我的问题是我可以并行打开的管道数量是否有任何限制?
是因为我开了太多进程吗?

最佳答案

您是否排除了竞争条件,即客户端试图连接到服务器尚未建立的管道?如果服务器上有很多事件线程,它很容易延迟应该开始监听的线程。这可以解释为什么它在一开始就有效。

一般来说,为每个客户端分配一个服务器线程并不能很好地扩展;您将通过线程池方法获得更好的性能。

关于c# - 什么是命名管道 (net.pipe) 限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12405134/

相关文章:

windows - 是否可以在 Windows 中使用命令行打开命名管道?

windows - 命名管道服务器,如何中断或超时等待客户端连接和传入数据

c# - c++/cli 仅将内部成员公开给托管类

.net - TagBuilder 从 MVC 3 beta 变为 RC

c# - 使用 .Net Core API 从 Azure Blob 存储异步流式传输视频

c# - 如何在C#中使用\in字符串

c# - WebBrowser - 查找呈现文本的高度

c++ - 无法在 kernel32.dll 中找到 GetOverlappedResultEx

c# - 当用户在c#中单击它时获取图像的来源

c# - 在方法中使用 Predicate<T> 或 Func<T> 进行过滤