在同一网络上的不同计算机上运行的进程之间进行通信的推荐方式

发布于 2024-08-24 17:16:01 字数 582 浏览 9 评论 0原文

我正在研究(希望).NET 软件解决方案的一个小功能,该功能将允许一个应用程序报告在同一网络上的多台计算机上运行的另一个应用程序的多个实例的状态。

我查看了 这篇关于命名管道的 MSDN 文章,并设置建立了一个简单的客户端/服务器项目,效果很好。但是,这只是在同一台计算机上运行的两个进程(因此对于 NamedPipeClientStream 构造函数,我将“.”作为 serverName 参数传递) 。尝试在同一网络上的不同计算机上运行同一项目会导致客户端进程失败,并报告找不到网络路径。

这可能肯定只是我在客户端进程中将错误的字符串作为serverName传递的问题。 (我尝试了 IP 地址以及我认为的机器的网络名称,但也许我的格式错误。)无论如何,有关让客户端/服务器 IPC 在单独的机器上工作的一些帮助在同一网络上将不胜感激。 (我也问这个问题,因为我什至不知道使用命名管道是否是最合乎逻辑的解决方案。)

I'm working on what should (hopefully) be a small feature for a .NET software solution that will allow one application to report on the status of multiple instances of another application running on more than one computer on the same network.

I took a look at this MSDN article on named pipes, and set up a simple client/server project that worked great. However, this was only two processes running on the same computer (so for the NamedPipeClientStream constructor, I passed "." as the serverName parameter). Attempting to run this same project on separate machines on the same network caused the client process to fail, reporting that the network path was not found.

This could definitely just be a matter of me passing the wrong string as serverName from within the client process. (I tried the IP address as well as what I believe was the machine's network name, but perhaps I had the format wrong.) In any case, some help on getting client/server IPC working on separate machines on the same network would be much appreciated. (I am also asking this question because I don't even know if using named pipes is the most logical solution in the first place.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

说不完的你爱 2024-08-31 17:16:01

命名管道可以工作,但如果所有计算机不在同一个域中,则很难使其工作。

当然,另一种选择就是使用套接字。使用套接字并不比使用命名管道复杂多少。

最后,如果所有应用程序都是 .NET,那么 WCF 也是一个选择。这里的主要好处是您不必担心在线协议,它只是一系列方法调用。尽管 WCF 确实在安全性和配置方面增加了一些开销。

Named pipes will work, but it's tricky to get it to work if all of the computers are not on the same domain.

Another option, of course, is just to use sockets. It's not much more complicated to use sockets than it is to use Named Pipes.

Finally, if all applications are .NET, then WCF is an option as well. The main benefit here is that you don't have to worry the over-the-wire protocol, it's just a series of methods calls. Though WCF does add some overhead in terms of security and configuration.

一世旳自豪 2024-08-31 17:16:01

MailSlots 是另一种可能适合您的替代方案,它允许将消息广播到目标计算机或本地网络。

我有一个封装在 C# 库中的开源实现,可能会有所帮助。它使用 MailSlot 实现进行网络传播,但也回退到 WM_COPYDATA 窗口消息或 IOStream,以便将消息分派到单个计算机上的所有进程。这绕过了只有一个进程可以读取 MailSlot 消息的限制。

http://thecodeking.github.com/XDMessaging.Net/

MailSlots is another alternative that might work for you, it allows messages to be broadcast to targeted machine or a local network.

I have an open source implementation wrapped in a C# library that may help. It uses a MailSlot implementation for network propagation, but also falls back to WM_COPYDATA windows messages or IOStreams in order to dispatch messages to all processes on a single machine. This gets around a limitation that only one process can read a MailSlot message.

http://thecodeking.github.com/XDMessaging.Net/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文