private void ProcessSend(SocketAsyncEventArgs e)
        {
            AsyncUserToken userToken = e.UserToken as AsyncUserToken;

            lock (userToken)
            {
                if (!userToken.IsActive)
                {
                    return;
                }

                userToken.SendEvent.Set();
                if (e.SocketError == SocketError.Success)
                {
                    OnSendSuccess(userToken);
                }
                else
                {
                    CloseClientSocket(userToken);
                }
            }
        }
        private void ProcessReceive(SocketAsyncEventArgs e)
        {
            AsyncUserToken userToken = e.UserToken as AsyncUserToken;

            lock (userToken)
            {
                if (!userToken.IsActive)
                {
                    return;
                }
                userToken.RecvEvent.Set();

                int count = userToken.ReceiveEventArgs.BytesTransferred;
                if (count > 0 && userToken.ReceiveEventArgs.SocketError == SocketError.Success)
                {
                    OnReceiveSuccess(userToken);
                }
                else
                {
                    CloseClientSocket(userToken);
                }
            }
        }
 public virtual void OnSendSuccess(AsyncUserToken token)
 {
     Interlocked.Add(ref m_totalSendBytes, token.SendEventArgs.BytesTransferred);
     token.ActiveDateTime = DateTime.Now;
 }
 /// <summary>
 /// 处理回应逻辑
 /// </summary>
 /// <returns></returns>
 protected virtual void OnReceiveSuccess(AsyncUserToken token)
 {
     Interlocked.Increment(ref m_totalSerial);
     Interlocked.Add(ref m_totalReceiveBytes, token.ReceiveEventArgs.BytesTransferred);
     token.ActiveDateTime = DateTime.Now;
 }