/// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <param name="repoteEndPointStr"></param>
        protected virtual void SendAsync(byte[] data, string repoteEndPointStr)
        {
            SocketAsyncEventArgs readEventArgs;
            var flag = ReadSocketEventArgsTable.TryGetValue(repoteEndPointStr, out readEventArgs);

            if (!flag || readEventArgs == null)
            {
                Logger.Error("{0}客户连接【{1}】无效", ServiceName, repoteEndPointStr);
                return;
            }
            var write = new SocketAsyncEventArgs();

            write.Completed   += OnSocketEventCompleted;
            write.AcceptSocket = (readEventArgs.UserToken as Socket);
            write.UserToken    = readEventArgs.UserToken;
            var client = (readEventArgs.UserToken as Socket);

            if (client != null)
            {
                write.SetBuffer(data, 0, data.Length);
                bool willRaiseEvent = client.SendAsync(write);
                if (!willRaiseEvent)
                {
                    ProcessSend(write);
                }
            }
            else
            {
                Logger.Error(ServiceName + ".SendAsync 连接已经断开");
            }
        }
        /// <summary>
        /// 关闭套件信息
        /// </summary>
        /// <param name="e"></param>
        protected void CloseClientSocket(SocketAsyncEventArgs e)
        {
            var client = e.UserToken as Socket;

            if (client == null)
            {
                return;
            }

            // close the socket associated with the client
            try
            {
                //保证资源清理
                SocketAsyncEventArgs readSocketEventArgs;
                ReadSocketEventArgsTable.TryRemove(client.RemoteEndPoint.ToString(), out readSocketEventArgs);
                e.UserToken = null;
                client.Shutdown(SocketShutdown.Send);
            }
            // throws if client process has already closed
            catch (Exception ex)
            {
                Logger.Error(ex, "CloseClientSocket");
            }
            client.Close();
            // decrement the counter keeping track of the total number of clients connected to the server
            Interlocked.Decrement(ref _mNumConnectedSockets);
            _mMaxNumberAcceptedClients.Release();
            Logger.Log(LogLevel.Trace, string.Format("关闭连接. 目前仍有{0}客户连接", _mNumConnectedSockets));
            // Free the SocketAsyncEventArg so they can be reused by another client
            _mReadPool.Push(e);
        }
        private void OnStoped()
        {
            _listenSocket.Close();
            var list = ReadSocketEventArgsTable.ToArray();

            ReadSocketEventArgsTable.Clear();
            foreach (var socketAsyncEventArgse in list)
            {
                var clientsocket = (Socket)socketAsyncEventArgse.Value.UserToken;
                if (clientsocket != null && clientsocket.Connected)
                {
                    // close the socket associated with the client
                    try
                    {
                        clientsocket.Shutdown(SocketShutdown.Both);
                    }
                    catch (Exception)
                    {
                        // throws if client process has already closed
                    }
                    finally
                    {
                        if (clientsocket.Connected)
                        {
                            clientsocket.Close();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 根据键值关闭套件信息
        /// </summary>
        /// <param name="key"></param>
        public void CloseClientSocket(string key)
        {
            SocketAsyncEventArgs readSocketEventArgs;
            var flag = ReadSocketEventArgsTable.TryRemove(key, out readSocketEventArgs);

            if (flag && readSocketEventArgs != null)
            {
                CloseClientSocket(readSocketEventArgs);
            }
        }
        private void ProcessAccept(SocketAsyncEventArgs e)
        {
            if (e.SocketError == SocketError.Success)
            {
                try
                {
                    if (e.AcceptSocket != null)
                    {
                        Interlocked.Increment(ref _mNumConnectedSockets);
                        Logger.Log(LogLevel.Trace, string.Format("建立连接. 目前有{0}客户连接",
                                                                 _mNumConnectedSockets));

                        //ReadEventArg object user token
                        SocketAsyncEventArgs readEventArgs = _mReadPool.Pop();
                        readEventArgs.UserToken = e.AcceptSocket;
                        //记录目前连接客户端
                        string key = e.AcceptSocket.RemoteEndPoint.ToString();
                        ReadSocketEventArgsTable.TryAdd(key, readEventArgs);
                        bool willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs);
                        if (!willRaiseEvent)
                        {
                            ProcessReceive(readEventArgs);
                        }
                    }
                    else
                    {
                        Logger.Error("AcceptEventArgCompleted SocketError:" + e.SocketError);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, ServiceName + ".ProcessAccept");
                }
            }
            else
            {
                Logger.Log(LogLevel.Trace, string.Format("连接状态{0}", e.SocketError));
            }
            // Accept the next connection request
            if (IsRunning)
            {
                StartAccept(e);
            }
        }