-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.cs
More file actions
33 lines (31 loc) · 831 Bytes
/
Helper.cs
File metadata and controls
33 lines (31 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace NetAzy
{
class Helper
{
/// <summary>
/// Resolves strimg ip or hostname
/// </summary>
/// <param name="str_ip">Hostname or IPAddress in string</param>
/// <returns>IPAddress instance or Exception on failure</returns>
public static IPAddress ResolveAdress(string str_ip)
{
IPAddress ip;
if (IPAddress.TryParse(str_ip, out ip))
{
if (str_ip == "0.0.0.0")
return IPAddress.Any;
return ip;
}
else
{
IPAddress[] ips = Dns.GetHostAddresses(str_ip);
return ips[0];
}
}
}
}