diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-08-05 19:41:30 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-08-05 19:41:30 +0000 |
commit | c011557b07abda8145d7a711095acdd4284fe367 (patch) | |
tree | ba7ef0529d8714b4aad20b2d04144d2e11896627 /examples/browse-services.c | |
parent | bf0db10cd964b708a77d2e1768500f57a1392023 (diff) |
Improve examples to do error checking
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@240 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'examples/browse-services.c')
-rw-r--r-- | examples/browse-services.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/browse-services.c b/examples/browse-services.c index c58d230..f2707fd 100644 --- a/examples/browse-services.c +++ b/examples/browse-services.c @@ -70,7 +70,8 @@ static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, Avah we free it. If the server is terminated before the callback function is called the server will free the resolver for us. */ - avahi_service_resolver_new(s, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, resolve_callback, s); + if (!(avahi_service_resolver_new(s, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, resolve_callback, s))) + g_message("Failed to resolve service '%s': %s", name, avahi_strerror(avahi_server_errno(s))); } int main(int argc, char*argv[]) { @@ -100,7 +101,10 @@ int main(int argc, char*argv[]) { } /* Create the service browser */ - sb = avahi_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, browse_callback, server); + if (!(sb = avahi_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, browse_callback, server))) { + g_message("Failed to create service browser: %s", avahi_strerror(avahi_server_errno(server))); + goto fail; + } /* Run the main loop */ main_loop = g_main_loop_new(NULL, FALSE); |