Пример #1
0
        /// <summary>
        /// Gets the host name from an IP address.
        /// </summary>
        /// <param name="ip">The IP address as string.</param>
        /// <returns>The host name for the given IP address or an empty string if the name could not be found (e.g. if the given string was no real IP address).</returns>
        public static string GetHostnameByIPAddress(string ip)
        {
            if (String.IsNullOrEmpty(ip) || !NetworkTools.IsStringIPAddress(ip))
            {
                return(String.Empty);
            }

            try
            {
                IPHostEntry hostEntry = Dns.GetHostEntry(ip);
                return(hostEntry.HostName);
            }
            catch (Exception)
            {
                return(String.Empty);
            }
        }
Пример #2
0
        private CheckSuspendResult Ping(string computername)
        {
            var ipAddress = NetworkTools.GetIPAddressByHostname(computername);

            if (ipAddress == null)
            {
                return(new CheckSuspendResult(false, String.Empty));
            }

            Ping p      = new Ping();
            var  result = p.Send(ipAddress);

            if (result.Status == IPStatus.Success)
            {
                return(new CheckSuspendResult(true, String.Format(Resources.Wsapm_Core.PingCheck_MachineOnlineReason, computername)));
            }
            else
            {
                return(new CheckSuspendResult(false, String.Empty));
            }
        }
Пример #3
0
 /// <summary>
 /// Gets a string array with available network interfaces.
 /// </summary>
 /// <returns>A string array containing all network interfaces on the machine. Might be an empty array if there are no network interfaces installed.</returns>
 public static string[] GetAvailableNetworkInterfaces()
 {
     return(NetworkTools.GetAvailableNetworkInterfaces());
 }