Esempio n. 1
0
        protected bool TCPServerStartFlag = false;   /* 冗余判断服务器是否启动 */
        #endregion

        /// <summary>
        /// 初始化服务器
        /// </summary>
        public void TCPServerInit()
        {
            _TCPServerSocketBufferManager.InitBuffer();

            SocketAsyncEventArgs _SocketAsyncEventArgs;

            /* 预分配SocketAsyncEventArgs对象池 */
            for (int count = 0; count < _TCPServerSocketSetting.DefaultMaxConnctions; count++)
            {
                _SocketAsyncEventArgs            = new SocketAsyncEventArgs();
                _SocketAsyncEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(TCPServerOnIOCompleted);
                _TCPServerSocketBufferManager.SetBuffer(_SocketAsyncEventArgs);

                _TCPServerSocketAsyncEventArgsPool.Push(_SocketAsyncEventArgs);
            }
        }