/// <summary>
        /// 初始化函数
        /// </summary>
        public void Init()
        {
            AsyncUserToken userToken;

            for (int i = 0; i < _maxClient; i++)
            {
                userToken = new AsyncUserToken(_bufferSize);
                userToken.ReceiveEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(OnIOCompleted);
                userToken.SendEventArgs.Completed    += new EventHandler <SocketAsyncEventArgs>(OnIOCompleted);
                _userTokenPool.Push(userToken);
            }
        }
Пример #2
0
        /// <summary>
        /// 初始化函数
        /// </summary>
        public void Init()
        {
            AsyncUserToken userToken;

            for (int i = 0; i < _maxClient; i++)
            {
                userToken = new AsyncUserToken(BufferSize);
                _userTokenPool.Push(userToken);
            }
            //心跳检测
            Thread tCheckClientHeartbeat = new Thread(CheckClientHeartbeat);

            tCheckClientHeartbeat.IsBackground = true;
            tCheckClientHeartbeat.Start();
        }
Пример #3
0
        /// <summary>
        /// 初始化函数
        /// </summary>
        public void Init()
        {
            AsyncUserToken userToken;

            for (int i = 0; i < _maxClient; i++)
            {
                userToken = new AsyncUserToken(_bufferSize);
                userToken.ReceiveEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(OnIOCompleted);
                userToken.SendEventArgs.Completed    += new EventHandler <SocketAsyncEventArgs>(OnIOCompleted);
                _userTokenPool.Push(userToken);
            }

            Thread prinThread = new Thread(() =>
            {
                while (true)
                {
                    PrintCurrentConnections();
                    Thread.Sleep(1000);
                }
            });

            prinThread.IsBackground = true;
            prinThread.Start();
        }