// .ctor without handle - create new
public Win32NamedPipeClient(NamedPipeClientStream owner, string serverName, string pipeName, PipeAccessRights desiredAccessRights, PipeOptions options, HandleInheritability inheritability)
{
name = String.Format("\\\\{0}\\pipe\\{1}", serverName, pipeName);
var att = new SecurityAttributesHack(inheritability == HandleInheritability.Inheritable);
is_async = (options & PipeOptions.Asynchronous) != PipeOptions.None;
opener = delegate {
var ret = Win32Marshal.CreateFile(name, desiredAccessRights, 0, ref att, 3, 0, IntPtr.Zero);
if (ret == new IntPtr(-1L))
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
return(new SafePipeHandle(ret, true));
};
this.owner = owner;
}