示例#1
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="options">the pipe options</param>
 public IpcPipe(IpcPipeOps options)
 {
     if (options == null)
     {
         options = IpcPipeOps.defaultIpcPIpeOps;
     }
     if (options.m_callBackObj != null)
     {
         throw new ArgumentException("callBackObj is null!");
     }
     lock (m_generalLock)
     {
         m_options = options;
         if (options.m_numOfWriteBytes == 0)
         {
             m_options.m_numOfWriteBytes = IpcConf.DEFAULT_WRITE_BUF_SIZE;
         }
         if (options.m_numOfReadBytes == 0)
         {
             m_options.m_numOfReadBytes = IpcConf.DEFAULT_READ_BUF_SIZE;
         }
     }
     m_readBuffer = new byte[m_options.m_numOfReadBytes];
     // Provide full access to the current user so more pipe instances can be created
     m_ps = new PipeSecurity();
     m_ps.AddAccessRule(
         new PipeAccessRule(WindowsIdentity.GetCurrent().User, PipeAccessRights.FullControl, AccessControlType.Allow)
         );
     m_ps.AddAccessRule(
         new PipeAccessRule(
             new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow
             )
         );
 }
示例#2
0
        /// <summary>
        /// Actual server start function
        /// </summary>
        protected override void Execute()
        {
            IpcStartStatus status = IpcStartStatus.SUCCESS;

            try
            {
                IpcPipeOps pipeOptions = new IpcPipeOps(m_options.m_pipeName, this, m_options.m_numOfReadBytes, m_options.m_numOfWriteBytes);
                for (int trav = 0; trav < m_options.m_maximumInstances; trav++)
                {
                    IpcPipe pipeInst = new IpcPipe(pipeOptions);
                    pipeInst.Create();
                }
                m_started = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + " >" + ex.StackTrace);
                m_started = false;
                status    = IpcStartStatus.FAIL_PIPE_CREATE_FAILED;
            }
            m_options.m_callBackObj.OnServerStarted(this, status);
        }