/// <summary> /// Create service record resolving enumerator /// </summary> /// <param name="proxy">The proxy endpoint(s) to use</param> /// <param name="record">The service record to resolve</param> /// <param name="ct"></param> /// <returns></returns> public static async Task <IDnsServiceResolver> CreateServiceRecordResolverAsync( SocketAddress proxy, DnsServiceRecord record, bool cacheOnly, CancellationToken ct) { if (string.IsNullOrEmpty(record.Name) || string.IsNullOrEmpty(record.Type) || record.Removed) { throw new ArgumentException("Invalid service, no name, not type or been removed", nameof(record)); } var socket = new BrowseSocket(Socket.Provider, BrowseRequest.Service); await socket.ConnectAsync(proxy ?? record.Interface, ct); await socket.BrowseBeginAsync(record.ToSocketAddress(), ct); return(new ServiceRecordResolver(record) { Socket = socket, CacheOnly = cacheOnly }); }
internal ServiceRecordResolver(DnsServiceRecord service) { _service = service; }
// // Resolve service record to a host name, port, plus txt records. // public static Task <IDnsServiceResolver> BrowseAsync(DnsServiceRecord record, CancellationToken ct) => BrowseAsync(record, false, ct);
// // Resolve service record to a host name, port, plus txt records. // public static Task <IDnsServiceResolver> BrowseAsync(DnsServiceRecord record, bool cached, CancellationToken ct) => BrowseAsync(null, record, cached, ct);
// // Resolve service record to a host name, port, plus txt records. // public static Task <IDnsServiceResolver> BrowseAsync(SocketAddress proxy, DnsServiceRecord record, CancellationToken ct) => BrowseAsync(proxy, record, false, ct);
/// <summary> /// Resolve service record to a host name, port, plus txt records. /// </summary> /// <param name="proxy"></param> /// <param name="service"></param> /// <param name="cached">Only return items until cache is exhausted</param> /// <param name="ct"></param> /// <returns></returns> public static Task <IDnsServiceResolver> BrowseAsync(SocketAddress proxy, DnsServiceRecord service, bool cached, CancellationToken ct) => BrowseClient.CreateServiceRecordResolverAsync(proxy, service, cached, ct);