/// <summary> /// Stops the currently running search or resolution. /// </summary> public void Stop() { TeardownWatchSocket(serviceHandle); if (serviceHandle != IntPtr.Zero) { mDNSImports.DNSServiceRefDeallocate(serviceHandle); serviceHandle = IntPtr.Zero; } browseReplyCb = null; domainSearchReplyCb = null; }
/// <summary> /// Starts a search for services of a given type within a given domain. /// </summary> /// <param name="type">Type of service to search for.</param> /// <param name="domain">Domain name in which to search.</param> /// <remarks> /// The <I>domain</I> argument can be an explicity domain name, the /// generic "local." (including the trailing period) domain name or /// an empty string ("") which represents the default registration domain. /// </remarks> public void SearchForService(String type, String domain) { Stop(); browseReplyCb = new mDNSImports.DNSServiceBrowseReply(BrowseReply); DNSServiceErrorType err = mDNSImports.DNSServiceBrowse(out serviceHandle, 0, 0, type, domain, browseReplyCb, IntPtr.Zero); if (err != DNSServiceErrorType.NoError) { throw new DNSServiceException("DNSServiceBrowse", err); } SetupWatchSocket(serviceHandle); }
/// <summary> /// Stops the currently running search or resolution. /// </summary> public void Stop() { /* FIXME: do i need to stop the poll? ... */ if (sdRef != IntPtr.Zero) { mDNSImports.DNSServiceRefDeallocate(sdRef); sdRef = IntPtr.Zero; } WaitStop(); browseReplyCb = null; /* garbage collected */ domainSearchReplyCb = null; if (gchSelf.IsAllocated) { gchSelf.Free(); } }
/// <summary> /// Starts a search for services of a given type within a given domain. /// </summary> /// <param name="type">Type of service to search for.</param> /// <param name="domain">Domain name in which to search.</param> /// <remarks> /// The <I>domain</I> argument can be an explicity domain name, the /// generic "local." (including the trailing period) domain name or /// an empty string ("") which represents the default registration domain. /// </remarks> public void SearchForService(String type, String domain) { Stop(); browseReplyCb = new mDNSImports.DNSServiceBrowseReply(BrowseReply); gchSelf = GCHandle.Alloc(this); DNSServiceErrorType err; err = mDNSImports.DNSServiceBrowse(out sdRef, 0, 0, type, domain, browseReplyCb, (IntPtr)gchSelf); if (err != DNSServiceErrorType.kDNSServiceErr_NoError) { throw new DNSServiceException("DNSServiceBrowse", err); } SetupWatchSocket(); }