Example how to browse for DNS-SD services using the client interface to avahi-daemon.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
static void resolve_callback(
const char *name,
const char *type,
const char *domain,
const char *host_name,
uint16_t port,
AVAHI_GCC_UNUSED void* userdata) {
assert(r);
switch (event) {
break;
fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
fprintf(stderr,
"\t%s:%u (%s)\n"
"\tTXT=%s\n"
"\tcookie is %u\n"
"\tis_local: %i\n"
"\tour_own: %i\n"
"\twide_area: %i\n"
"\tmulticast: %i\n"
"\tcached: %i\n",
host_name, port, a,
t,
avahi_string_list_get_service_cookie(txt),
}
}
}
static void browse_callback(
const char *name,
const char *type,
const char *domain,
void* userdata) {
assert(b);
switch (event) {
return;
fprintf(stderr, "(Browser) NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain);
break;
fprintf(stderr, "(Browser) REMOVE: service '%s' of type '%s' in domain '%s'\n", name, type, domain);
break;
break;
}
}
assert(c);
}
}
int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) {
int error;
int ret = 1;
fprintf(stderr, "Failed to create simple poll object.\n");
goto fail;
}
if (!client) {
fprintf(stderr,
"Failed to create client: %s\n",
avahi_strerror(error));
goto fail;
}
goto fail;
}
ret = 0;
fail:
if (sb)
if (client)
if (simple_poll)
return ret;
}