/// <summary>
        /// Accept callback method for not SSL connection
        /// </summary>
        /// <param name="ar">The socket server</param>
        private void AcceptCallback(IAsyncResult ar)
        {
            AbstractSocketServer server = (AbstractSocketServer)ar.AsyncState;

            try
            {
                // Get the socket that handles the client request.
                Socket handler = server.listener.EndAccept(ar);
                Trace.WriteLine("Start incoming connection ...");
                handler.Blocking = true;
                AbstractTcpSocketClientHandler clientHandler = this.GetHandler(handler, null);
                clientHandler.KeepAlive             = this.KeepAlive;
                clientHandler.ReceiveMessageEvent  += new ReceiveMessageDelegate(server.OnReceiveMessage);
                clientHandler.CloseConnectionEvent += new SocketConnectionDelegate(server.clientHandler_CloseConnectionEvent);
                // Add the clilent to the client list
                server.clientList.AddClient(this.GetClientInfo(clientHandler));
                // Notify the connection event
                server.OnConnection(clientHandler);
                // Start to receive data from this client
                clientHandler.StartReceive();
                Trace.WriteLine("New connection completed");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Failed to accept incoming connection. Exception", ex));
            }
            finally
            {
                // Signal the main thread to continue.
                server.listenerCompleteConnectionEvent.Set();
            }
        }
        /// <summary>
        /// Accept callback method for SSL connection.
        /// </summary>
        /// <param name="ar">The socket server</param>
        private void AcceptSSLCallback(IAsyncResult ar)
        {
            AbstractSocketServer server    = (AbstractSocketServer)ar.AsyncState;
            SslStream            sslStream = null;

            try
            {
                // Get the socket that handles the client request.
                TcpClient sslTcpClient = server.sslListener.EndAcceptTcpClient(ar);
                Trace.WriteLine("Start incoming ssl connection ...");
                sslStream = new SslStream(sslTcpClient.GetStream(), false, new RemoteCertificateValidationCallback(server.OnVerifyClientCertificate));
                sslStream.AuthenticateAsServer(server.serverCertificate, true, SslProtocols.Ssl3, false);
                Socket handler = sslTcpClient.Client;
                handler.Blocking = true;
                AbstractTcpSocketClientHandler clientHandler = this.GetHandler(handler, sslStream);
                clientHandler.KeepAlive             = this.KeepAlive;
                clientHandler.ReceiveMessageEvent  += new ReceiveMessageDelegate(server.OnReceiveMessage);
                clientHandler.CloseConnectionEvent += new SocketConnectionDelegate(server.clientHandler_CloseConnectionEvent);
                server.OnConnection(clientHandler);
                server.clientList.AddClient(this.GetClientInfo(clientHandler));
                clientHandler.StartReceive();
                Trace.WriteLine("New connection completed");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Failed to accept incoming connection. Exception", ex));
                try
                {
                    if (sslStream != null)
                    {
                        sslStream.Close();
                        sslStream.Dispose();
                    }
                }
                catch (Exception ex2)
                {
                    Trace.WriteLine(ex2);
                }
            }
            finally
            {
                // Signal the main thread to continue.
                server.listenerCompleteConnectionEvent.Set();
            }
        }