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

Alex Chen alex_chen at filemaker.com
Thu Mar 31 09:46:52 PDT 2011


Thanks, Trent.
    That's what I thought after looking through the header files and document, too.  But since the callback is invoked from the polling thread, wouldn't it make more sense to include such information as input to the callback? After all, the client ( the library part ) should be able to extract the information polled from the server daemon, right?

If you have played with Apple's Bonjour SDK, you will know what I mean.  There seems to be an Apple mDNS compatible library.  But can it be used with Avahi's 'polling' mechanism so do I have to write my own polling thread?

Alex

On Mar 30, 2011, at 11:46 PM, Trent Lloyd wrote:

> 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
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/avahi



More information about the avahi mailing list