我想问你如何设置从远程客户端访问我的命名管道服务器。到目前为止,我认为NamedPipes只能用于同一台计算机上的进程间通信,但基于http://msdn.microsoft.com/en-us/library/windows/desktop/aa365150%28v=vs.85%29.aspx,应该可以通过设置PIPE_ACCEPT_REMOTE_CLIENTS/PIPE_REJECT_REMOTE_CLIENTS来允许/不允许从远程计算机访问。我没有找到如何在.NET中设置此功能的简单方法。我想PipeSecurity可能会以某种方式用于它,但我没有找到一个简单的方法。允许从远程客户端访问命名管道服务器
我目前的解决方案允许所有用户访问我在当前机器上的命名管道。有人可以改进我的解决方案,以允许从另一台机器访问吗?
谢谢。
public NamedPipeServerStream CreateNamedPipeServer(string pipeName)
{
const int BufferSize = 65535;
var pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.ReadWrite, AccessControlType.Allow));
pipeSecurity.AddAccessRule(new PipeAccessRule("Administrators", PipeAccessRights.ReadWrite, AccessControlType.Allow));
return new NamedPipeServerStream(pipeName, PipeDirection.InOut, countOfServerInstancesToCreate, PipeTransmissionMode.Message, PipeOptions.Asynchronous,
BufferSize,
BufferSize);
}
我想指出,允许从计算机A访问NamedPipeServer运行的计算机B并非易事。请参阅http://stackoverflow.com/questions/719353/win32-named-pipes-and-remote-clients以获取更多信息 – user2126375 2014-10-04 19:23:08