I would like to ask you how to set up possible access to my named pipe server from remote clients. Until now I thought that NamedPipes can be used just for inter-process communication on same computer, but based on http://msdn.microsoft.com/en-us/library/windows/desktop/aa365150%28v=vs.85%29.aspx it should be possible by setting PIPE_ACCEPT_REMOTE_CLIENTS / PIPE_REJECT_REMOTE_CLIENTS to allow/ not allow to access from remote computers. I did not find simple way how to setup this functionality in .NET. I suppose that PipeSecurity could be somehow used for it but I did not find a simple way.
My current solution allows to access all users to my named pipe on current machine. Can somebody improve my solution to allow access from another machine as well?
Thanks.
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);
}