简体   繁体   English

Win32命名管道和远程客户端

[英]Win32 named pipes and remote clients

Can I access a named pipe on computer A from computer B given computer A's IP address? 我可以从计算机B访问计算机A的命名管道给定计算机A的IP地址吗? If so, what do I need to do to make this happen? 如果是这样,我需要做些什么来实现这一目标?

Yes you can communicate across the network via named pipes. 是的,您可以通过命名管道在网络上进行通信。 You specify the pipe name like a UNC path: 您指定管道名称,如UNC路径:

\\\\computername\\pipe\\pipename

or via IP 或通过IP

\\\\192.168.0.100\\pipe\\pipename

You can do this for any LAN machine, or for any remote machine connected to your LAN via VPN. 您可以为任何LAN计算机或通过VPN连接到LAN的任何远程计算机执行此操作。

You use all of the same pipe Win32 API functions such as CreateFile . 您使用所有相同的管道Win32 API函数,如CreateFile To create the pipe you use CreateNamedPipe . 要创建管道,请使用CreateNamedPipe

Before you can use a remote pipe, you must have a valid connection to the remote computer. 在使用远程管道之前,必须具有与远程计算机的有效连接。 To do this you would use an API like WNetUseConnection . 为此,您将使用类似WNetUseConnection的API。 Or if your computer is on the same domain, or has the same u/p you don't need to use WNetUseConnection at all. 或者,如果您的计算机位于同一个域中,或者具有相同的u / p,则根本不需要使用WNetUseConnection。

If you are running your program as a service, you cannot access LAN resources with the local system account. 如果您将程序作为服务运行,则无法使用本地系统帐户访问LAN资源。 The service would have to be configured with another account. 该服务必须配置另一个帐户。

Named pipes can be used to provide IPC between processes on different computers across a network. 命名管道可用于在网络上不同计算机上的进程之间提供IPC。 Refer MSDN . 请参阅MSDN

If you are having Windows XP SP2, Windows Server 2003 SP1 and later versions, then don't forget to enable the named pipe filtering. 如果您使用的是Windows XP SP2,Windows Server 2003 SP1和更高版本,则不要忘记启用命名管道过滤。 Refer here . 请参考这里

Be aware, pipes under Windows are bloody awful. 请注意,Windows下的管道非常糟糕。 There's a lot of crucial detail you need to get exactly right, or they fail strangely and the documentation isn't up to scratch. 你需要很多关键细节才能完全正确,或者它们会奇怪地失败并且文档不是最新的。

If you can, use sockets. 如果可以,请使用套接字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM