Bug Fixed DNS Tests
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -11,16 +12,19 @@ namespace Networking_Tools {
|
||||
|
||||
public string[] GetIPs() {
|
||||
List<string> ipAddresses = new List<string>();
|
||||
IPHostEntry iphost = Dns.GetHostEntry(HostName);
|
||||
|
||||
foreach (IPAddress theAddress in iphost.AddressList) {
|
||||
if (theAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) {
|
||||
ipAddresses.Add(theAddress.ToString());
|
||||
try {
|
||||
IPHostEntry iphost = Dns.GetHostEntry(HostName);
|
||||
|
||||
foreach (IPAddress theAddress in iphost.AddressList) {
|
||||
if (theAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) {
|
||||
ipAddresses.Add(theAddress.ToString());
|
||||
}
|
||||
}
|
||||
} catch (SocketException) {
|
||||
ipAddresses.Add("");
|
||||
}
|
||||
|
||||
return ipAddresses.ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user