public static IPEndPoint FindManagementPort(IPAddress ip, int timeout = 1) { var client = new MdnsClient(); var results = client.QueryAll(MANAGEMENT_SERVICE, timeout); foreach (var result in results) { if (result.IP.ToString() == ip.ToString()) { return(new IPEndPoint(ip, result.Port)); } } throw new Exception("No MDNS Server with the IP (" + ip.ToString() + ") could be found."); }
public static IPEndPoint FindManagementPort(string hostname, int timeout = 1) { var client = new MdnsClient(); var results = client.QueryAll(MANAGEMENT_SERVICE, timeout); foreach (var result in results) { if (result.Name.Split('.')[0].ToLower() == hostname.ToLower()) { return(new IPEndPoint(result.IP, result.Port)); } } throw new Exception("No MDNS Server with the name (" + hostname + ") could be found."); }