﻿using System;
using System.Net.NetworkInformation;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HazTech.Util
{
    public class PingLib
    {
        List<string> args = new List<string>();
        public PingLib()
        {
        }
        public PingLib(string ipaddr)
        {

        }
        public void PingCmd()
        {
            using (Ping ping = new Ping())
            {
                foreach (string comp in args)
                {
                    try
                    {
                        Console.Write("    {0}...", comp);
                        PingReply reply = ping.Send(comp, 100);
                        if (reply.Status == IPStatus.Success)
                        {
                            Console.WriteLine("Success - IP Address:{0}", reply.Address, reply.RoundtripTime);
                        }
                        else
                        {
                            Console.WriteLine(reply.Status);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error ({0})",
                            ex.InnerException.Message);
                    }
                }
            }
        }
    }
}
