GetHostName() public static method

public static GetHostName ( ) : string
return string
Beispiel #1
0
        /// <summary>Gets the host name of the local machine.</summary>
        public static string GetHostName()
        {
            NameResolutionPal.EnsureSocketsAreInitialized();

            ValueStopwatch stopwatch = NameResolutionTelemetry.Log.BeforeResolution(string.Empty);

            string name;

            try
            {
                name = NameResolutionPal.GetHostName();
            }
            catch when(LogFailure(stopwatch))
            {
                Debug.Fail("LogFailure should return false");
                throw;
            }

            if (NameResolutionTelemetry.Log.IsEnabled())
            {
                NameResolutionTelemetry.Log.AfterResolution(stopwatch, successful: true);
            }

            if (NetEventSource.Log.IsEnabled())
            {
                NetEventSource.Info(null, name);
            }
            return(name);
        }
Beispiel #2
0
        } // InternalGetHostByAddress

        /*****************************************************************************
         * Function :    gethostname
         *
         * Abstract:     Queries the hostname from DNS
         *
         * Input Parameters:
         *
         * Returns: String
         ******************************************************************************/

        /// <devdoc>
        ///    <para>Gets the host name of the local machine.</para>
        /// </devdoc>
        public static string GetHostName()
        {
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Print("Dns.GetHostName");
            }

            return(NameResolutionPal.GetHostName());
        }
Beispiel #3
0
        /// <summary>Gets the host name of the local machine.</summary>
        public static string GetHostName()
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(null, null);
            }
            NameResolutionPal.EnsureSocketsAreInitialized();

            return(NameResolutionPal.GetHostName());
        }
Beispiel #4
0
        } // InternalGetHostByAddress

        /*****************************************************************************
         * Function :    gethostname
         *
         * Abstract:     Queries the hostname from DNS
         *
         * Input Parameters:
         *
         * Returns: String
         ******************************************************************************/

        /// <devdoc>
        ///    <para>Gets the host name of the local machine.</para>
        /// </devdoc>
        public static string GetHostName()
        {
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Print("Dns.GetHostName");
            }

            NameResolutionPal.EnsureSocketsAreInitialized();
            return(NameResolutionPal.GetHostName());
        }
Beispiel #5
0
        /// <summary>Gets the host name of the local machine.</summary>
        public static string GetHostName()
        {
            NameResolutionPal.EnsureSocketsAreInitialized();

            string name = NameResolutionPal.GetHostName();

            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(null, name);
            }
            return(name);
        }
Beispiel #6
0
        /// <summary>Gets the host name of the local machine.</summary>
        public static string GetHostName()
        {
            long startingTimestamp = NameResolutionTelemetry.Log.BeforeResolution(string.Empty);

            string name;

            try
            {
                name = NameResolutionPal.GetHostName();
            }
            catch when(LogFailure(startingTimestamp))
            {
                Debug.Fail("LogFailure should return false");
                throw;
            }

            NameResolutionTelemetry.Log.AfterResolution(startingTimestamp, successful: true);

            if (NetEventSource.Log.IsEnabled())
            {
                NetEventSource.Info(null, name);
            }
            return(name);
        }
Beispiel #7
0
        } // InternalGetHostByAddress

        /*****************************************************************************
         * Function :    gethostname
         *
         * Abstract:     Queries the hostname from DNS
         *
         * Input Parameters:
         *
         * Returns: String
         ******************************************************************************/

        /// <devdoc>
        ///    <para>Gets the host name of the local machine.</para>
        /// </devdoc>
        public static string GetHostName()
        {
            GlobalLog.Print("Dns.GetHostName");
            return(NameResolutionPal.GetHostName());
        }