Compare commits
No commits in common. "main" and "latest" have entirely different histories.
43
Program.cs
43
Program.cs
|
|
@ -11,34 +11,29 @@ namespace SharpDNSResolver
|
|||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Count() == 0)
|
||||
try
|
||||
{
|
||||
Console.WriteLine("You must provide at least one host!");
|
||||
Console.WriteLine("Usage: <prog.exe> <host1> [<host2> host<n>]");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
if(args.Count() == 0)
|
||||
{
|
||||
Console.WriteLine("You must provide an host!");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
string hostname = args[0];
|
||||
IPHostEntry hostEntry = Dns.GetHostEntry(hostname);
|
||||
|
||||
int cpt = 0;
|
||||
string hostname;
|
||||
IPHostEntry hostEntry;
|
||||
for (cpt = 0; cpt < args.Length; cpt++)
|
||||
Console.WriteLine($"Host : {hostEntry.HostName}");
|
||||
|
||||
Console.WriteLine("Ip address:");
|
||||
foreach (IPAddress ipAddress in hostEntry.AddressList)
|
||||
{
|
||||
Console.WriteLine($" {ipAddress}");
|
||||
}
|
||||
}
|
||||
catch (System.Net.Sockets.SocketException ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
hostname = args[cpt];
|
||||
hostEntry = Dns.GetHostEntry(hostname);
|
||||
Console.WriteLine($"\nHost : {hostEntry.HostName}");
|
||||
Console.WriteLine("Ip address:");
|
||||
foreach (IPAddress ipAddress in hostEntry.AddressList)
|
||||
{
|
||||
Console.WriteLine($" {ipAddress}");
|
||||
}
|
||||
}
|
||||
catch (System.Net.Sockets.SocketException ex)
|
||||
{
|
||||
Console.WriteLine($"Error : {ex.Message}");
|
||||
}
|
||||
Console.WriteLine($"Error : {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue