/// <summary>
        /// Stops server.
        /// </summary>
        public override void Stop()
        {
            if (ServerStatus == SocketServerStatus.Stop)
            {
                return;
            }

            ServerStatus = SocketServerStatus.Stop;
            _listener.Stop();
            while (SocketClients.Count > 0)
            {
                SocketClientSsl socketClient = (SocketClientSsl)SocketClients[0];
                socketClient.Disconnect();
                if (SocketClients.Contains(socketClient))
                {
                    SocketClients.Remove(socketClient);
                }
            }
        }
        /// <summary>
        /// Ends the pending of asynchronous accept of new clients.
        /// </summary>
        /// <param name="ar"></param>
        private void AcceptCallBack(IAsyncResult ar)
        {
            try
            {
                var listener = (TcpListener)ar.AsyncState;
                if (ServerStatus != SocketServerStatus.Start || !listener.Server.IsBound)
                {
                    return;
                }

                Socket socket = listener.EndAcceptSocket(ar);
                var    client = new SocketClientSsl(socket);
                client.Context         = this.Context;
                client.Connected      += (s, e) => { OnConnected(e); };
                client.Disconnected   += SocketClientDisconnected;
                client.ReceivedData   += (s, e) => { OnReceivedData(e); };
                client.SentData       += (s, e) => { OnSentData(e); };
                client.Error          += (s, e) => { OnError(e); };
                client.SocketError    += (s, e) => { OnSocketError(e); };
                client.SocketSecurity += (s, e) => { OnSocketSecurity(e); };
                SocketClients.Add(client);
                client.BeginAuthenticateAsServer(ClientCertificateRequired, CheckCertificateRevocation, ServerCertificate, CertificateValidationCallback, SslProtocol);
                ContinueAcceptConnections();
            }
            catch (SocketException e)
            {
                if (e.ErrorCode != 10004)
                {
                    OnSocketError(new SocketErrorEventArgs(LocalEndPoint, e));
                }
            }
            catch (Exception e)
            {
                OnError(new ErrorEventArgs(LocalEndPoint, e));
            }
        }