개정판 366f00c2
dns 체크 에러 수정
Change-Id: I9fd9b9d37c7c2529795ab14f46f58b157d911809
CommonLib/DNSHelper.cs | ||
---|---|---|
27 | 27 |
foreach (IPAddress dnsAdress in dnsAddresses) |
28 | 28 |
{ |
29 | 29 |
if (dnsAdress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) |
30 |
return dnsAdress; |
|
30 |
{ |
|
31 |
try |
|
32 |
{ |
|
33 |
var host = Dns.GetHostEntry(dnsAdress); |
|
34 |
|
|
35 |
if (host != null) |
|
36 |
{ |
|
37 |
return dnsAdress; |
|
38 |
} |
|
39 |
} |
|
40 |
catch (Exception ex) |
|
41 |
{ |
|
42 |
if (ex.InnerException is System.Net.Sockets.SocketException) |
|
43 |
{ |
|
44 |
System.Diagnostics.Debug.WriteLine((ex.InnerException as System.Net.Sockets.SocketException).SocketErrorCode); |
|
45 |
} |
|
46 |
//return dnsAdress; |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
31 | 50 |
} |
32 | 51 |
} |
33 | 52 |
} |
53 |
|
|
34 | 54 |
return null; |
35 | 55 |
} |
36 | 56 |
|
... | ... | |
38 | 58 |
{ |
39 | 59 |
IPHostEntry result = null; |
40 | 60 |
|
41 |
await Task.Factory.StartNew(() =>
|
|
61 |
try
|
|
42 | 62 |
{ |
43 |
try |
|
44 |
{ |
|
45 |
var ipaddress = CommonLib.DNSHelper.GetDnsAdress(); |
|
63 |
var ipaddress = CommonLib.DNSHelper.GetDnsAdress(); |
|
46 | 64 |
|
47 |
result = Dns.GetHostEntry(ipaddress); |
|
48 |
} |
|
49 |
catch (System.Net.Sockets.SocketException ex) |
|
65 |
result = await Dns.GetHostEntryAsync(ipaddress); |
|
66 |
} |
|
67 |
catch (Exception ex) |
|
68 |
{ |
|
69 |
if (ex.InnerException is System.Net.Sockets.SocketException) |
|
50 | 70 |
{ |
51 |
if (ex.SocketErrorCode == System.Net.Sockets.SocketError.HostNotFound) |
|
52 |
{ |
|
53 |
System.Diagnostics.Debug.WriteLine("DNS SocketError"); |
|
54 |
result = null; |
|
55 |
} |
|
71 |
System.Diagnostics.Debug.WriteLine((ex.InnerException as System.Net.Sockets.SocketException).SocketErrorCode); |
|
56 | 72 |
} |
57 |
catch (Exception ex)
|
|
73 |
else
|
|
58 | 74 |
{ |
59 |
throw ex; |
|
75 |
|
|
76 |
System.Diagnostics.Debug.WriteLine(ex.ToString()); |
|
60 | 77 |
} |
61 |
});
|
|
78 |
} |
|
62 | 79 |
|
63 | 80 |
System.Diagnostics.Debug.WriteLine("DNS END"); |
64 | 81 |
|
내보내기 Unified diff