public static ConvertAddress ( IPAddress, address ) : UdpIPv4Address | ||
address | IPAddress, | |
return | UdpIPv4Address |
public override UdpIPv4Address[] ResolveHostAddresses(string host) { if (host == null) { throw new ArgumentNullException("host", "argument was null"); } if (host.Length == 0) { throw new ArgumentException("host name was empty", "host"); } return((from x in Dns.GetHostAddresses(host) select DotNetPlatform.ConvertAddress(x)).ToArray <UdpIPv4Address>()); }
private DotNetInterface ParseInterface(NetworkInterface n) { HashSet <UdpIPv4Address> hashSet = new HashSet <UdpIPv4Address>(UdpIPv4Address.Comparer.Instance); HashSet <UdpIPv4Address> hashSet2 = new HashSet <UdpIPv4Address>(UdpIPv4Address.Comparer.Instance); HashSet <UdpIPv4Address> hashSet3 = new HashSet <UdpIPv4Address>(UdpIPv4Address.Comparer.Instance); IPInterfaceProperties iPInterfaceProperties = null; try { iPInterfaceProperties = n.GetIPProperties(); } catch { return(null); } if (iPInterfaceProperties != null) { try { foreach (GatewayIPAddressInformation current in iPInterfaceProperties.GatewayAddresses) { try { if (current.Address.AddressFamily == AddressFamily.InterNetwork) { hashSet.Add(DotNetPlatform.ConvertAddress(current.Address)); } } catch { } } } catch { } try { foreach (IPAddress current2 in iPInterfaceProperties.DnsAddresses) { try { if (current2.AddressFamily == AddressFamily.InterNetwork) { hashSet.Add(DotNetPlatform.ConvertAddress(current2)); } } catch { } } } catch { } try { foreach (UnicastIPAddressInformation current3 in iPInterfaceProperties.UnicastAddresses) { try { if (current3.Address.AddressFamily == AddressFamily.InterNetwork) { UdpIPv4Address item = DotNetPlatform.ConvertAddress(current3.Address); hashSet2.Add(item); hashSet.Add(new UdpIPv4Address(item.Byte3, item.Byte2, item.Byte1, 1)); } } catch { } } } catch { } try { foreach (MulticastIPAddressInformation current4 in iPInterfaceProperties.MulticastAddresses) { try { if (current4.Address.AddressFamily == AddressFamily.InterNetwork) { hashSet3.Add(DotNetPlatform.ConvertAddress(current4.Address)); } } catch { } } } catch { } if (hashSet2.Count == 0 || hashSet.Count == 0) { return(null); } } return(new DotNetInterface(n, hashSet.ToArray <UdpIPv4Address>(), hashSet2.ToArray <UdpIPv4Address>(), hashSet3.ToArray <UdpIPv4Address>())); }