diff --git a/src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs b/src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs index 1eca52e..d354106 100644 --- a/src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs +++ b/src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs @@ -142,14 +142,24 @@ private void OnResolveReply(ServiceRef sdRef, ServiceFlags flags, uint interface sd_ref.Process(); } + + if (hostentry.AddressList != null) + { + ServiceResolvedEventHandler handler = Resolved; + if (handler != null) + { + handler(this, new ServiceResolvedEventArgs(this)); + } + } } - + private void OnQueryRecordReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, ServiceError errorCode, string fullname, ServiceType rrtype, ServiceClass rrclass, ushort rdlen, IntPtr rdata, uint ttl, IntPtr context) { switch(rrtype) { case ServiceType.A: + case ServiceType.AAAA: IPAddress address; if(rdlen == 4) { @@ -181,11 +191,6 @@ private void OnQueryRecordReply(ServiceRef sdRef, ServiceFlags flags, uint inter hostentry.AddressList = new IPAddress [] { address }; } - ServiceResolvedEventHandler handler = Resolved; - if(handler != null) { - handler(this, new ServiceResolvedEventArgs(this)); - } - break; case ServiceType.TXT: if(TxtRecord != null) { @@ -197,8 +202,11 @@ private void OnQueryRecordReply(ServiceRef sdRef, ServiceFlags flags, uint inter default: break; } - - sdRef.Deallocate(); + + if ((flags & ServiceFlags.MoreComing) != ServiceFlags.MoreComing) + { + sdRef.Deallocate(); + } } public bool IsResolved {