コード例 #1
0
 public PipeConnectionListener(Uri pipeUri, HostNameComparisonMode hostNameComparisonMode, int bufferSize, List <SecurityIdentifier> allowedSids, bool useCompletionPort, int maxConnections)
 {
     PipeUri.Validate(pipeUri);
     this.pipeUri = pipeUri;
     this.hostNameComparisonMode = hostNameComparisonMode;
     this.allowedSids            = allowedSids;
     this.bufferSize             = bufferSize;
     this.pendingAccepts         = new List <PendingAccept>();
     this.useCompletionPort      = useCompletionPort;
     this.maxInstances           = Math.Min(maxConnections, 0xff);
 }
コード例 #2
0
        private void PrepareConnect(Uri remoteUri, TimeSpan timeout, out string resolvedAddress, out BackoffTimeoutHelper backoffHelper)
        {
            TimeSpan span;

            PipeUri.Validate(remoteUri);
            if (DiagnosticUtility.ShouldTraceInformation)
            {
                TraceUtility.TraceEvent(TraceEventType.Information, 0x4002a, System.ServiceModel.SR.GetString("TraceCodeInitiatingNamedPipeConnection"), new StringTraceRecord("Uri", remoteUri.ToString()), this, null);
            }
            resolvedAddress = GetPipeName(remoteUri);
            if (timeout >= TimeSpan.FromMilliseconds(300.0))
            {
                span = TimeoutHelper.Add(timeout, TimeSpan.Zero - TimeSpan.FromMilliseconds(150.0));
            }
            else
            {
                span = Ticks.ToTimeSpan((Ticks.FromMilliseconds(150) / 2L) + 1L);
            }
            backoffHelper = new BackoffTimeoutHelper(span, TimeSpan.FromMinutes(5.0));
        }
コード例 #3
0
 internal static string GetPipeName(Uri uri)
 {
     string[] strArray   = new string[] { "+", uri.Host, "*" };
     bool[]   flagArray2 = new bool[2];
     flagArray2[0] = true;
     bool[] flagArray = flagArray2;
     for (int i = 0; i < strArray.Length; i++)
     {
         for (int j = 0; j < flagArray.Length; j++)
         {
             for (string str = PipeUri.GetPath(uri); str.Length > 0; str = PipeUri.GetParentPath(str))
             {
                 string sharedMemoryName = PipeUri.BuildSharedMemoryName(strArray[i], str, flagArray[j]);
                 try
                 {
                     PipeSharedMemory memory = PipeSharedMemory.Open(sharedMemoryName, uri);
                     if (memory != null)
                     {
                         try
                         {
                             string pipeName = memory.PipeName;
                             if (pipeName != null)
                             {
                                 return(pipeName);
                             }
                         }
                         finally
                         {
                             memory.Dispose();
                         }
                     }
                 }
                 catch (AddressAccessDeniedException exception)
                 {
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(System.ServiceModel.SR.GetString("EndpointNotFound", new object[] { uri.AbsoluteUri }), exception));
                 }
             }
         }
     }
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(System.ServiceModel.SR.GetString("EndpointNotFound", new object[] { uri.AbsoluteUri }), new PipeException(System.ServiceModel.SR.GetString("PipeEndpointNotFound", new object[] { uri.AbsoluteUri }))));
 }
コード例 #4
0
 public void Listen()
 {
     lock (this.ThisLock)
     {
         if (!this.isListening)
         {
             string sharedMemoryName = PipeUri.BuildSharedMemoryName(this.pipeUri, this.hostNameComparisonMode, true);
             if (!PipeSharedMemory.TryCreate(this.allowedSids, this.pipeUri, sharedMemoryName, out this.sharedMemory))
             {
                 PipeSharedMemory result = null;
                 Uri    uri  = new Uri(this.pipeUri, Guid.NewGuid().ToString());
                 string str2 = PipeUri.BuildSharedMemoryName(uri, this.hostNameComparisonMode, true);
                 if (PipeSharedMemory.TryCreate(this.allowedSids, uri, str2, out result))
                 {
                     result.Dispose();
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(PipeSharedMemory.CreatePipeNameInUseException(5, this.pipeUri));
                 }
                 sharedMemoryName  = PipeUri.BuildSharedMemoryName(this.pipeUri, this.hostNameComparisonMode, false);
                 this.sharedMemory = PipeSharedMemory.Create(this.allowedSids, this.pipeUri, sharedMemoryName);
             }
             this.isListening = true;
         }
     }
 }