Exemplo n.º 1
0
        /// <summary>
        /// Accepts new connection.
        /// </summary>
        /// <param name="ar">Begin accept async result.</param>
        protected virtual void DoAcceptSocket(IAsyncResult ar)
        {
            if (OnConnectionAccepted != null && m_Active)
            {
                Socket acceptedSocket = ServiceSocket.EndAccept(ar);

                if (acceptedSocket != null && Firewall.ValidateRequest(acceptedSocket))
                {
                    NetworkHelper.SetCommonSocketOptions(ref acceptedSocket);
                    OnConnectionAccepted(acceptedSocket);
                    IncrementAcceptedConnectionsCount(ref AcceptedConnections);
                }
#if DEBUG_SERVICE
                else
                {
                    Logger.WriteLine(Source.Listener, "Null socket in DoAcceptSocket( IAsyncResult ar ) method.");
                }
#endif
                if (m_Active)
                {
                    DoBeginAccept();
                }
            }
        }