[avahi] How to get the service name from a callback

Trent Lloyd lathiat at bur.st
Wed Mar 30 23:46:15 PDT 2011


Alex,

On 31/03/2011, at 6:31 AM, Alex Chen wrote:

> I am trying to use Avahi to publish a service.  The callback API of avahi_entry_group_new() does not seem to contain a parameter that the caller to retrieve the original service name used in the avahi_entry_group_add_service() call.  I need to get the name and try a different name in case there is a name conflict.  The sample code uses a 'global' variable for this purpose but it is not a good practice.
> 
> I found the definition of AvahiEntryGroup structure in avahi-client/internal.h, which is not available in Ubuntu's package, from the source but could not find anything useful.
> Apple's Bonjour API for such callback has the service name, service type and domain name passed back as parameters.  How do I get such information?

The thing to do would be to pass the information in with the "userdata" parameter, which is fed to the callback.


Regards,
Trent


More information about the avahi mailing list