This is guile-avahi.info, produced by makeinfo version 6.7 from guile-avahi.texi. INFO-DIR-SECTION The Algorithmic Language Scheme START-INFO-DIR-ENTRY * Guile-Avahi: (Guile-Avahi). Guile bindings for Avahi. END-INFO-DIR-ENTRY This file documents Guile-Avahi. Copyright (C) 2007, 2008 Ludovic Courtès Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the author.  File: guile-avahi.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) Using Avahi in Guile Scheme Programs ************************************ This document describes Guile-Avahi version 0.4.1. It was last updated in December 2010. * Menu: * Introduction:: What this is about. * Conventions:: Naming conventions and other idiosyncrasies. * Examples:: Quick start. * API Reference:: The Scheme Avahi programming interface. * Concept Index:: Concepts. * Procedure Index:: Scheme Procedures. * Variable Index:: Scheme Variables.  File: guile-avahi.info, Node: Introduction, Next: Conventions, Prev: Top, Up: Top 1 Introduction ************** Guile-Avahi (http://www.nongnu.org/guile-avahi/) provides GNU Guile "bindings" to the Avahi library (http://avahi.org/). In other words, it makes it possible to write Scheme programs that use the facilities of Avahi. Avahi itself is a C library that implements the multicast DNS (http://multicastdns.org/) (mDNS) and DNS Service Discovery (http://dns-sd.org/) (DNS-SD) protocols, sometimes erroneously referred to as "Bonjour". Together, these protocols provide support for fully decentralized host naming and service publication and discovery. They are key components of the so-called Zero-Configuration Networking Stack (http://www.zeroconf.org/) ("Zeroconf"). More precisely, Guile-Avahi provides bindings for the "client" library of Avahi. The client library allows application to use service discovery by transparently connecting them to the Avahi "system-wide daemon" using D-Bus (http://dbus.freedesktop.org). This daemon actually implements the DNS-SD protocol and handles service discovery and publication on behalf of applications running on the same host. Thus, the functionality of Guile-Avahi could be provided to Guile Scheme applications by writing a D-Bus client to the Avahi daemon in Scheme. Alas, no Scheme-friendly D-Bus implementation was available at the time Guile-Avahi was started, hence the approach taken by Guile-Avahi. This document describes the Scheme API to Avahi offered by Guile-Avahi. The reader is assumed to have basic knowledge of the protocol and library. Please send bug reports and comments to the Guile-Avahi mailing list .  File: guile-avahi.info, Node: Conventions, Next: Examples, Prev: Introduction, Up: Top 2 Conventions ************* This chapter details the conventions used in Guile-Avahi, as well as specificities of the mapping of the C API to Scheme. * Menu: * Enumerates and Constants:: Representation of C-side constants. * Procedure Names:: Naming conventions. * Explicit Finalization:: Most objects must be explicitly freed. * Error Handling:: Exceptions.  File: guile-avahi.info, Node: Enumerates and Constants, Next: Procedure Names, Prev: Conventions, Up: Conventions 2.1 Enumerates and Constants ============================ Lots of enumerates and constants are used in the Avahi C API. For each C enumerate type, a disjoint Scheme type is used--thus, enumerate values and constants are not represented by Scheme symbols nor by integers. This makes it impossible to use an enumerate value of the wrong type on the Scheme side: such errors are automatically detected by type-checking. The enumerate values are bound to variables exported by the '(avahi)' and other modules within the 'avahi' hierarchy. These variables are named according to the following convention: * All variable names are lower-case; the underscore '_' character used in the C API is replaced by hyphen '-'. * All variable names are prepended by the name of the enumerate type and the slash '/' character. * In some cases, the variable name is made more explicit than the one of the C API, e.g., by avoid abbreviations. Consider for instance this C-side enumerate: typedef enum { AVAHI_CLIENT_S_REGISTERING, AVAHI_CLIENT_S_RUNNING, AVAHI_CLIENT_S_COLLISION, AVAHI_CLIENT_FAILURE, AVAHI_CLIENT_CONNECTING } AvahiClientState; The corresponding Scheme values are bound to the following variables exported by the '(avahi client)' module: client-state/s-registering client-state/s-running client-state/s-collision client-state/failure client-state/connecting Hopefully, most variable names can be deduced from this convention. Scheme-side "enumerate" values can be compared using 'eq?' (*note equality predicates: (guile)Equality.). Consider the following example: (let ((client (make-client ...))) ;; ;; ... ;; ;; Check the client state. (if (eq? (client-state client) client-state/failure) (format #t "Oh, we failed."))) In addition, all enumerate values can be converted to a human-readable string, in a type-specific way. For instance, '(watch-event->string watch-event/in)' yields '"in"'. Note that these strings may not be sufficient for use in a user interface since they are fairly concise and not internationalized.  File: guile-avahi.info, Node: Procedure Names, Next: Explicit Finalization, Prev: Enumerates and Constants, Up: Conventions 2.2 Procedure Names =================== Unlike C functions in Avahi, the corresponding Scheme procedures are named in a way that is close to natural English. Abbreviations are also avoided. For instance, the Scheme procedure corresponding to 'avahi_client_get_version' is named 'client-server-version'. The 'avahi_' prefix is always omitted from variable names since a similar effect can be achieved using Guile's nifty binding renaming facilities, should it be needed (*note (guile)Using Guile Modules::).  File: guile-avahi.info, Node: Explicit Finalization, Next: Error Handling, Prev: Procedure Names, Up: Conventions 2.3 Explicit Finalization ========================= Except for 'client' objects, all objects created by the Avahi client API are local representative of objects implemented by the system-wide Avahi daemon. For instance, 'make-service-browser' returns a "service browser" object which is actually a proxy to a daemon-implemented service browser (*note Service Browsing::). In other words, the Avahi daemon allocates resources (objects) on behalf of its clients. While the Avahi daemon can reclaim resources allocated on behalf of a client program when that program exits, it cannot automatically determine when such resources become unneeded and reclaimable while the program is running. Thus, clients must _explicitly_ tell the daemon when an object is no longer needed. Consequently, except for 'client' objects, objects manipulated by Guile-Avahi programs must be freed using the appropriate 'free' procedure. For instance, objects created by 'make-service-browser' must eventually be freed by 'free-service-browser!'. Additional procedures are available to determine whether a particular object has already been freed; for instance, 'freed-service-browser?' returns '#t' when the given service browser has already been freed. Of course, freed objects are no longer usable; procedures that are passed a previously freed object will raise an 'error/invalid-object' exception (*note Error Handling::). Note that all such client-side proxy objects are _not_ subject to garbage collection until they have been explicitly freed. Therefore, it is important to free them when they are no longer needed! As an exception, 'client' objects as returned by 'make-client' are subject to garbage collection and need not be explicitly freed. This is because client programs will usually create only one client object whose lifetime is that of the program itself.  File: guile-avahi.info, Node: Error Handling, Prev: Explicit Finalization, Up: Conventions 2.4 Error Handling ================== Avahi errors are implemented as Scheme exceptions (*note exceptions in Guile: (guile)Exceptions.). Each time a Avahi function returns an error, an exception with key 'avahi-error' is raised. The additional arguments that are thrown include an error code and the name of the Avahi procedure that raised the exception. The error code is pretty much like an enumerate value: it is one of the 'error/' variables exported by the '(avahi)' module (*note Enumerates and Constants::). Exceptions can be turned into error messages using the 'error->string' procedure. The following examples illustrates how Avahi exceptions can be handled: (let ((poll (make-simple-poll))) ;; ;; ... ;; (catch 'avahi-error (lambda () (run-simple-poll (simple-poll poll))) (lambda (key err function . currently-unused) (format (current-error-port) "an Avahi error was raised by `~a': ~a~%" function (error->string err))))) Again, error values can be compared using 'eq?': ;; `avahi-error' handler. (lambda (key err function . currently-unused) (if (eq? err error/no-daemon) (format (current-error-port) "~a: the Avahi daemon is not running~%" function))) Note that the 'catch' handler is currently passed only 3 arguments but future versions might provide it with additional arguments. Thus, it must be prepared to handle more than 3 arguments, as in this example.  File: guile-avahi.info, Node: Examples, Next: API Reference, Prev: Conventions, Up: Top 3 Examples ********** This chapter lists examples that illustrate common use cases. * Menu: * Publishing a Service:: Advertising a service. * Browsing Published Services:: Looking for services. * Resolving Services:: Finding a service's IP address and port.  File: guile-avahi.info, Node: Publishing a Service, Next: Browsing Published Services, Prev: Examples, Up: Examples 3.1 Publishing a Service ======================== The following example shows the simplest way to publish a service. There are several stages: * Create an Avahi client using 'make-client'. This will actually connect the application to the Avahi daemon that will eventually perform operations on behalf of the application. * When the client switches to the running state (i.e., 'client-state/s-running'), create an "entry group" with 'make-entry-group' and add a service (or several services, addresses, etc.) to it. * Commit the entry group using 'commit-entry-group'. * When all entries in the group have been successfully published, the group's call-back is invoked and passed the 'entry-group-state/established' state. The application must keep running so that the service remains published. Here is the complete example: (use-modules (avahi) (avahi client) (avahi client publish)) (define (group-callback group state) (if (eq? state entry-group-state/established) (format #t "service is now published!~%"))) (define client-callback (let ((group #f)) (lambda (client state) (if (eq? state client-state/s-running) (begin ;; The client is now running so we can create an entry ;; group and publish a service. (set! group (make-entry-group client group-callback)) (add-entry-group-service! group interface/unspecified protocol/unspecified '() "my-avahi-service" "_some-service-type._tcp" #f #f ;; any domain and host 1234 ;; the port number ;; additional `txt' properties "scheme=yes" "java=no") ;; Commit the entry group, i.e., actually publish ;; the service. (commit-entry-group group)))))) ;; The main loop. (let* ((poll (make-simple-poll)) (client (make-client (simple-poll poll) '() ;; no flags client-callback))) (and (client? client) ;; Run forever. (run-simple-poll poll))) Of course, publishing a host address or service subtype works similarly.  File: guile-avahi.info, Node: Browsing Published Services, Next: Resolving Services, Prev: Publishing a Service, Up: Examples 3.2 Browsing Published Services =============================== Browsing advertised services requires a number of stages. First, an Avahi daemon client must be created, as usual (*note Publishing a Service::). (use-modules (avahi) (avahi client) (avahi client lookup)) (define %service-type ;; The type of services we are looking for. "_workstation._tcp") (define (service-browser-callback browser interface protocol event service-name service-type domain flags) (if (eq? event browser-event/new) (format #t "found service `~a' of type `~a'~%" service-name service-type))) (define client-callback (let ((browser #f)) (lambda (client state) (if (eq? state client-state/s-running) ;; Now that the client is up and running, create a service ;; browser looking for services of type `%service-type' on ;; any network interface and using any protocol. (set! browser (make-service-browser client interface/unspecified protocol/unspecified %service-type #f '() service-browser-callback)))))) (let* ((poll (make-simple-poll)) (client (make-client (simple-poll poll) '() ;; no flags client-callback))) (and (client? client) (run-simple-poll poll))) In this example, the service type being looked for is '"_workstation._tcp"'. It is used to advertise the presence of computers on a local area network, rather than an actual service.  File: guile-avahi.info, Node: Resolving Services, Prev: Browsing Published Services, Up: Examples 3.3 Resolving Services ====================== The previous example allowed us to _find_ services of a given type, but did not provide us with information such as the IP address of the host providing the service and the port number where the service can be found. To obtain this information, a "service resolver" must be launched, e.g., by augmenting the service browser call-back as follows: (define (service-browser-callback browser interface protocol event service-name service-type domain flags) (define (service-resolver-callback resolver interface protocol event service-name service-type domain host-name address-type address port txt flags) ;; Handle service resolution events. (cond ((eq? event resolver-event/found) (format #t "resolved service `~a' at `~a:~a'~%" service-name host-name port)) ((eq? event resolver-event/failure) (format #t "failed to resolve service `~a'~%" service-name)))) (if (eq? event browser-event/new) (begin (format #t "found service `~a' of type `~a'~%" service-name service-type) ;; Launch a service resolver for the service we just found. (make-service-resolver (service-browser-client browser) interface protocol service-name service-type domain protocol/unspecified '() service-resolver-callback)))) Now you know all the important things you need to know to benefit from Avahi!  File: guile-avahi.info, Node: API Reference, Next: Concept Index, Prev: Examples, Up: Top 4 API Reference *************** This chapter documents Guile-Avahi Scheme procedures. Note that further details can be found in the Avahi C API reference (http://avahi.org/). * Menu: * Core Interface:: Common Avahi facilities. * Client Interface:: Client-related facilities. * Service Publication:: Publishing services. * Service Browsing:: Discovering published services.  File: guile-avahi.info, Node: Core Interface, Next: Client Interface, Prev: API Reference, Up: API Reference 4.1 Core Interface ================== This section lists the Scheme procedures exported by the '(avahi)' module. These procedures are mainly related to "polls", the building block of event loops in Avahi programs. Polls come in three flavors: * The "simple poll" provides simple, single-threaded event dispatching. It essentially hangs on 'select()', processes D-Bus I/O events, and invokes the relevant client call-backs when appropriate. * The "threaded poll" processes events similarly but in a separate thread of execution. * Finally, the "guile poll" allows you to create customized event loops. This is useful, for instance, in single-threaded programs that process events coming not only from Avahi but also from other sources (e.g., GTK+ events, networking events, etc.). Creating and manipulating polls is achieved using the procedures below. -- Scheme Procedure: unlock-threaded-poll threaded-poll Unlock the event look object associated with THREADED-POLL. -- Scheme Procedure: lock-threaded-poll threaded-poll Lock the event loop associated with THREADED-POLL. Use this if you want to access the event loop object (e.g., creating a new event source) from anything but the event loop helper thread, i.e. not from callbacks. -- Scheme Procedure: quit-threaded-poll threaded-poll Quit the event loop associated with THREADED-POLL responsible for running the event loop. It must be called from outside said thread (i.e., not from callbacks). -- Scheme Procedure: stop-threaded-poll threaded-poll Stop the helper thread associated with THREADED-POLL responsible for running the event loop. It must be called from outside said thread (i.e., not from callbacks). -- Scheme Procedure: start-threaded-poll threaded-poll Start the helper thread associated with THREADED-POLL, which is responsible for running the event loop. Callbacks are called from the helper thread. Thus, synchronization may be required among threads. -- Scheme Procedure: threaded-poll threaded-poll Return the 'poll' object associated with THREADED-POLL. -- Scheme Procedure: make-threaded-poll Return a 'threaded-poll' object. A threaded poll is essentially an event loop that processes events from the Avahi daemon in its own thread. -- Scheme Procedure: run-simple-poll simple-poll Run the event loop of SIMPLE-POLL until either an error occurs or a quit request is scheduled. In the former case, an error is raised; in the latter, '#f' is returned. -- Scheme Procedure: iterate-simple-poll simple-poll [sleep-time] Handle events registered by SIMPLE-POLL. If SLEEP-TIME is not specified, the function blocks until an I/O event occurs. If SLEEP-TIME is specified, it is the maximum number of milliseconds of blocking. Return '#f' is a quit request has been scheduled, '#t' otherwise. -- Scheme Procedure: simple-poll simple-poll Return the 'poll' object associated with SIMPLE-POLL. -- Scheme Procedure: make-simple-poll Return a 'simple-poll' object. This is the easiest way to handle I/O of Avahi 'client' objects and similar. -- Scheme Procedure: guile-poll guile-poll Return the 'poll' object associated with GUILE-POLL. -- Scheme Procedure: make-guile-poll new-watch update-watch! free-watch new-timeout update-timeout! free-timeout Return a 'guile-poll' object that can then be used to handle I/O events for Avahi objects such as clients. All arguments should be procedures: * NEW-WATCH and NEW-TIMEOUT are invoked when the poll-using code requires a new file descriptor to be watched after, or a new timeout to be honored, respectively. NEW-WATCH is passed a 'watch' object and a list of 'watch-event' values; NEW-TIMEOUT is passed a TIMEOUT object and a number of seconds and nanoseconds representing the absolute date when the timeout expires, or '#f' if the newly created timeout is disabled. * UPDATE-WATCH! and UPDATE-TIMEOUT! are called to modify a previously created watch or timeout. UPDATE-WATCH! is passed the 'watch' object and a new list of events; UPDATE-TIMEOUT! is passed a new expiration time or '#f'. * Finally, FREE-WATCH and FREE-TIMEOUT are called when the poll is asked to to no longer look handle them. For instance, when FREE-WATCH is called, the event loop code may remove the associated file descriptor from the list of descriptors passed to 'select'. The Guile-Avahi source code distribution comes with a detailed example. -- Scheme Procedure: timeout? obj Return true if OBJ is of type 'timeout'. -- Scheme Procedure: watch? obj Return true if OBJ is of type 'watch'. -- Scheme Procedure: threaded-poll? obj Return true if OBJ is of type 'threaded-poll'. -- Scheme Procedure: guile-poll? obj Return true if OBJ is of type 'guile-poll'. -- Scheme Procedure: simple-poll? obj Return true if OBJ is of type 'simple-poll'. -- Scheme Procedure: poll? obj Return true if OBJ is of type 'poll'. -- Scheme Procedure: interface->string enumval Return a string describing ENUMVAL, a 'interface' value. -- Scheme Procedure: protocol->string enumval Return a string describing ENUMVAL, a 'protocol' value. -- Scheme Procedure: watch-event->string enumval Return a string describing ENUMVAL, a 'watch-event' value. -- Scheme Procedure: error->string enumval Return a string describing ENUMVAL, a 'error' value. The low-level API for watches, timeouts, and "guile polls", all of which serve as the basic for the creation of customized event loops (using 'make-guile-poll') is described below. In practice, you should only need it in applications where the Avahi event loop needs to be integrated in some other event loop; in other cases, the "simple poll" or "threaded poll" should be enough. -- Scheme Procedure: set-timeout-user-data! timeout data Associated DATA (an arbitrary Scheme object) with TIMEOUT. -- Scheme Procedure: timeout-user-data timeout Return the user-specified data associated with TIMEOUT. -- Scheme Procedure: timeout-value timeout Return the expiration time for TIMEOUT as two values: the number of seconds and nanoseconds. If TIMEOUT is disabled, both values are '#f'. -- Scheme Procedure: set-watch-user-data! watch data Associated DATA (an arbitrary Scheme object) with WATCH. -- Scheme Procedure: watch-user-data watch Return the user-specified data associated with WATCH. -- Scheme Procedure: watch-events watch Return the events of interest (a list of 'watch-event/' values) for WATCH. -- Scheme Procedure: watch-fd watch Return the file descriptor associated with WATCH. -- Scheme Procedure: invoke-timeout timeout Invoke the call-back associated with TIMEOUT. This notifies the interested code that the timeout associated with TIMEOUT has been reached. The return value is unspecified. An 'error/invalid-object' error is raised if TIMEOUT is disabled or is no longer valid. -- Scheme Procedure: invoke-watch watch events Invoke the call-back associated with WATCH. This notifies the interested code that the events listed in EVENTS (a list of 'watch-event/' values) occurred on the file descriptor associated with WATCH. The return value is unspecified. An 'error/invalid-object' error is raised if WATCH is no longer valid.  File: guile-avahi.info, Node: Client Interface, Next: Service Publication, Prev: Core Interface, Up: API Reference 4.2 Client Interface ==================== This section lists the Scheme procedures exported by the '(avahi client)' module. -- Scheme Procedure: client-state client Return the state (a 'client-state/' value) of CLIENT. -- Scheme Procedure: client-host-fqdn client Return the fully qualified domain name (FQDN) of the server CLIENT is connected to. -- Scheme Procedure: client-host-name client Return the host name of the server CLIENT is connected to. -- Scheme Procedure: client-server-version client Return the version (a string) of the server the client is connected to. -- Scheme Procedure: make-client poll flags callback Return a new Avahi client. The client will use POLL (a 'poll' object as returned by, e.g., '(simple-poll (make-simple-poll))') for I/O management. In addition, when the client state changes, 'callback' (a two-argument procedure) will be invoked and passed the client object and a client-state value. FLAGS must be a list of client flags (i.e., 'client-flag/' values). -- Scheme Procedure: client? obj Return true if OBJ is of type 'client'. -- Scheme Procedure: client-flag->string enumval Return a string describing ENUMVAL, a 'client-flag' value. -- Scheme Procedure: client-state->string enumval Return a string describing ENUMVAL, a 'client-state' value. The FLAGS argument expected by 'make-client' is a list containing zero or more values among the following: -- Scheme Variable: client-flag/ignore-user-config Don't read user configuration. -- Scheme Variable: client-flag/no-fail Don't fail if the daemon is not available when 'make-client' is called; instead enter 'client-state/connecting' state and wait for the daemon to appear.  File: guile-avahi.info, Node: Service Publication, Next: Service Browsing, Prev: Client Interface, Up: API Reference 4.3 Service Publication ======================= The service publication API is provided by the '(avahi client publish)'. To publish services, one must first create a client for the Avahi daemon (*note Client Interface::). -- Scheme Procedure: alternative-service-name service-name Find an alternative name to SERVICE-NAME. If called with an original service name, '" #2"' is appended. Afterwards the number is incremented on each call (i.e., '"foo"' becomes '"foo #2"', which becomes '"foo #3"', and so on). -- Scheme Procedure: alternative-host-name hostname Find an alternative name to HOSTNAME. If called with an original host name, '"2"' is appended. Afterwards the number is incremented on each call (i.e., '"foo"' becomes '"foo2"', which becomes '"foo3"', and so on). -- Scheme Procedure: add-entry-group-address! group interface protocol publish-flags fqdn address-protocol address Add to GROUP a mapping from fully-qualified domain name FQDN to address ADDRESS. Depending on ADDRESS-PROTOCOL (a 'protocol/' value), ADDRESS should be a 32-bit or 128-bit integer (for IPv4 and IPv6, respectively) in host byte order (*note (guile)Network Address Conversion::). -- Scheme Procedure: update-entry-group-service! group interface protocol publish-flags service-name service-type domain [txt...] Update the service named SERVICE-NAME in GROUP. -- Scheme Procedure: add-entry-group-service-subtype! group interface protocol publish-flags service-name service-type domain subtype Add SUBTYPE as a sub-type of a service already present in GROUP. You may add as many subtypes for a service as you wish. -- Scheme Procedure: add-entry-group-service! group interface protocol publish-flags service-name service-type domain host port [txt...] Add a service of type SERVICE-TYPE (e.g., '"_http._tcp"') named SERVICE-NAME to GROUP. PORT should be an integer telling which port this service is listening on; HOST can be a string indicating which host it is running on, or '#f' to let the daemon decide by itself (recommended). Likewise, DOMAIN can be '#f' (recommended) or a string indicating the domain where this service is to be registered. Additionaly TXT arguments should be string denoting additional 'txt' properties (e.g., '"color-printer=yes"'). Finally, INTERFACE and PROTOCOL denote, respectively, the network interface and protocol used to publish the service. INTERFACE may be 'interface/unspecified', in which case the daemon will choose the most appropriate interface, or it can be a string (e.g., '"eth0"'), or an integer OS-provided integer index; similarly, PROTOCOL may be 'protocol/unspecified', in which case the daemon will choose a protocol, or it can be any other 'protocol/' value. -- Scheme Procedure: entry-group-client group Return the client used by GROUP. -- Scheme Procedure: entry-group-empty? group Return '#t' if GROUP is empty, '#f' otherwise. -- Scheme Procedure: entry-group-state group Return the state of GROUP, i.e., an 'entry-group-state/' value. -- Scheme Procedure: reset-entry-group! group Reset GROUP. -- Scheme Procedure: commit-entry-group group Commit entry group GROUP, i.e., register its entries on the network. It is an error to commit an empty group. -- Scheme Procedure: make-entry-group client callback Return a new entry group using CLIENT and CALLBACK as the state-change notification procedure. CALLBACK should be a two-argument procedure. It will be passed the group object and the group entry's state (i.e., a 'group-entry-state/' value). -- Scheme Procedure: publish-flag->string enumval Return a string describing ENUMVAL, a 'publish-flag' value. -- Scheme Procedure: entry-group-state->string enumval Return a string describing ENUMVAL, a 'entry-group-state' value. -- Scheme Procedure: entry-group? obj Return true if OBJ is of type 'entry-group'. -- Scheme Procedure: freed-entry-group? obj Return '#t' if OBJ is an object of type 'entry-group' that has already been explicitly freed. -- Scheme Procedure: free-entry-group! obj Explicitly free OBJ, an object of type 'entry-group'. The PUBLISH-FLAGS argument expected by 'add-entry-group-service!' and similar procedures is a list containing zero or more values among the following: -- Scheme Variable: publish-flag/unique For raw records: The RRset is intended to be unique. -- Scheme Variable: publish-flag/no-probe For raw records: Though the RRset is intended to be unique no probes shall be sent. -- Scheme Variable: publish-flag/no-announce For raw records: Do not announce this RR to other hosts. -- Scheme Variable: publish-flag/allow-multiple For raw records: Allow multiple local records of this type, even if they are intended to be unique. -- Scheme Variable: publish-flag/no-reverse For address records: don't create a reverse (PTR) entry. -- Scheme Variable: publish-flag/no-cookie For service records: do not implicitly add the local service cookie to TXT data. -- Scheme Variable: publish-flag/update Update existing records instead of adding new ones. -- Scheme Variable: publish-flag/use-wide-area Register the record using wide area DNS (i.e., unicast DNS update). -- Scheme Variable: publish-flag/use-multicast Register the record using multicast DNS.  File: guile-avahi.info, Node: Service Browsing, Prev: Service Publication, Up: API Reference 4.4 Service Browsing ==================== The service discovery API is provided by the '(avahi client lookup)' module. Service discovery typically consists of two phases: "browsing" where one can find, e.g., available services, and "resolution" where one can, e.g., get detailed information about a discovered service such as its IP address. All browsers and resolvers support the following "lookup flags": -- Scheme Variable: lookup-flag/use-wide-area Force lookup via wide-area DNS. -- Scheme Variable: lookup-flag/use-multicast Force lookup via multicast DNS. -- Scheme Variable: lookup-flag/no-txt When doing service resolving, don't lookup TXT record. -- Scheme Variable: lookup-flag/no-address When doing service resolving, don't lookup A/AAAA record. Procedures to create browsers and resolvers are described below. -- Scheme Procedure: make-address-resolver client interface protocol address-type address lookup-flags callback Return a new address resolver using the specified CLIENT, INTERFACE, etc., that will resolve the host name corresponding to ADDRESS of type ADDRESS-TYPE (either 'protocol/inet' for an IPv4 address or 'protocol/inet6' for an IPv6 address). As usual, ADDRESS should be the raw IP address in host byte order (*note (guile)Network Address Conversion::). Upon resolution, CALLBACK is invoked and passed: * the address resolver object; * an interface name or number (depending on the OS); * the protocol (i.e., one of the 'protocol/' values); * a resolver event type (i.e., one of the 'resolver-event/' values); * the host IP address type (i.e., ADDRESS-TYPE); * the host IP address (i.e., ADDRESS); * the corresponding host name; * lookup result flags (i.e., a list of 'lookup-result-flag/' values). An exception may be raised on failure. -- Scheme Procedure: make-host-name-resolver client interface protocol host-name a-protocol lookup-flags callback Return a new host-name resolver using the specified CLIENT, INTERFACE, etc., that will resolve HOST-NAME, i.e., find the corresponding IP address. Upon resolution, CALLBACK is invoked and passed: * the host-name resolver object; * an interface name or number (depending on the OS); * the protocol (i.e., one of the 'protocol/' values); * a resolver event type (i.e., one of the 'resolver-event/' values); * the host name; * the host IP address type (i.e., 'protocol/inet' for an IPv4 address and 'protocol/inet6' for an IPv6 address); * the host IP address in host byte order (*note (guile)Network Address Conversion::); * lookup result flags (i.e., a list of 'lookup-result-flag/' values). An exception may be raised on failure. -- Scheme Procedure: make-service-resolver client interface protocol service-name type domain a-protocol lookup-flags callback Return a new service resolver using the specified CLIENT, INTERFACE, etc., that will resolve the host name, IP address, port and 'txt' properties of the service of type TYPE named SERVICE-NAME. Upon resolution, CALLBACK is invoked and passed: * the service type resolver object; * an interface name or number (depending on the OS); * the protocol (i.e., one of the 'protocol/' values); * a resolver event type (i.e., one of the 'resolver-event/' values); * the service name; * the service type (e.g., '"_http._tcp"'); * the domain; * the host name (name of the host the service is running on); * the host IP address type (i.e., 'protocol/inet' for an IPv4 address and 'protocol/inet6' for an IPv6 address); * the host IP address in host byte order (*note (guile)Network Address Conversion::); * a list of 'txt' properties (strings); * lookup result flags (i.e., a list of 'lookup-result-flag/' values). An exception may be raised on failure. -- Scheme Procedure: make-service-browser client interface protocol type domain lookup-flags callback Return a new service browser using the specified CLIENT, INTERFACE, etc. Upon browsing events (discovery, removal, etc.) CALLBACK will be called and passed: * the service browser object; * an interface name or number (depending on the OS); * the protocol (i.e., one of the 'protocol/' values); * a browser event type (i.e., one of the 'browser-event/' values); * the service name; * the service type (e.g., '"_http._tcp"'); * the domain; * lookup result flags (i.e., a list of 'lookup-result-flag/' values). -- Scheme Procedure: make-service-type-browser client interface protocol domain lookup-flags callback Return a new service type browser using the specified CLIENT, INTERFACE, etc. Upon browsing events (discovery, removal, etc.) CALLBACK will be called and passed: * the service type browser object; * an interface name or number (depending on the OS); * the protocol (i.e., one of the 'protocol/' values); * a browser event type (i.e., one of the 'browser-event/' values); * a service type (e.g., '"_http._tcp"'); * the domain; * lookup result flags (i.e., a list of 'lookup-result-flag/' values). -- Scheme Procedure: make-domain-browser client interface protocol domain domain-browser-type lookup-flags callback Return a new domain browser of type DOMAIN-BROWSER-TYPE (a 'domain-browser-type/' value) for DOMAIN that uses CLIENT. Upon browsing events (discovery, removal, etc.) CALLBACK will be called and passed: * the domain browser object; * an interface name or number (depending on the OS); * the protocol (i.e., one of the 'protocol/' values); * a browser event type (i.e., one of the 'browser-event/' values); * the domain; * lookup result flags (i.e., a list of 'lookup-result-flag/' values). -- Scheme Procedure: address-resolver-client address-resolver Return the client associated with ADDRESS-RESOLVER. -- Scheme Procedure: host-name-resolver-client host-name-resolver Return the client associated with HOST-NAME-RESOLVER. -- Scheme Procedure: service-resolver-client service-resolver Return the client associated with SERVICE-RESOLVER. -- Scheme Procedure: service-browser-client service-browser Return the client associated with SERVICE-BROWSER. -- Scheme Procedure: service-type-browser-client service-type-browser Return the client associated with SERVICE-TYPE-BROWSER. -- Scheme Procedure: domain-browser-client domain-browser Return the client associated with DOMAIN-BROWSER. -- Scheme Procedure: lookup-result-flag->string enumval Return a string describing ENUMVAL, a 'lookup-result-flag' value. -- Scheme Procedure: lookup-flag->string enumval Return a string describing ENUMVAL, a 'lookup-flag' value. -- Scheme Procedure: resolver-event->string enumval Return a string describing ENUMVAL, a 'resolver-event' value. -- Scheme Procedure: browser-event->string enumval Return a string describing ENUMVAL, a 'browser-event' value. -- Scheme Procedure: domain-browser-type->string enumval Return a string describing ENUMVAL, a 'domain-browser-type' value. -- Scheme Procedure: address-resolver? obj Return true if OBJ is of type 'address-resolver'. -- Scheme Procedure: freed-address-resolver? obj Return '#t' if OBJ is an object of type 'address-resolver' that has already been explicitly freed. -- Scheme Procedure: free-address-resolver! obj Explicitly free OBJ, an object of type 'address-resolver'. -- Scheme Procedure: host-name-resolver? obj Return true if OBJ is of type 'host-name-resolver'. -- Scheme Procedure: freed-host-name-resolver? obj Return '#t' if OBJ is an object of type 'host-name-resolver' that has already been explicitly freed. -- Scheme Procedure: free-host-name-resolver! obj Explicitly free OBJ, an object of type 'host-name-resolver'. -- Scheme Procedure: service-resolver? obj Return true if OBJ is of type 'service-resolver'. -- Scheme Procedure: freed-service-resolver? obj Return '#t' if OBJ is an object of type 'service-resolver' that has already been explicitly freed. -- Scheme Procedure: free-service-resolver! obj Explicitly free OBJ, an object of type 'service-resolver'. -- Scheme Procedure: service-type-browser? obj Return true if OBJ is of type 'service-type-browser'. -- Scheme Procedure: freed-service-type-browser? obj Return '#t' if OBJ is an object of type 'service-type-browser' that has already been explicitly freed. -- Scheme Procedure: free-service-type-browser! obj Explicitly free OBJ, an object of type 'service-type-browser'. -- Scheme Procedure: service-browser? obj Return true if OBJ is of type 'service-browser'. -- Scheme Procedure: freed-service-browser? obj Return '#t' if OBJ is an object of type 'service-browser' that has already been explicitly freed. -- Scheme Procedure: free-service-browser! obj Explicitly free OBJ, an object of type 'service-browser'. -- Scheme Procedure: domain-browser? obj Return true if OBJ is of type 'domain-browser'. -- Scheme Procedure: freed-domain-browser? obj Return '#t' if OBJ is an object of type 'domain-browser' that has already been explicitly freed. -- Scheme Procedure: free-domain-browser! obj Explicitly free OBJ, an object of type 'domain-browser'. Browser and resolver call-backs are usually passed a browser event or resolver event value, respectively, among the following: -- Scheme Variable: browser-event/new The object is new on the network. -- Scheme Variable: browser-event/remove The object has been removed from the network. -- Scheme Variable: browser-event/cache-exhausted One-time event, to notify the user that all entries from the caches have been sent. -- Scheme Variable: browser-event/all-for-now One-time event, to notify the user that more records will probably not show up in the near future, i.e., all cache entries have been read and all static servers been queried. -- Scheme Variable: browser-event/failure Browsing failed. -- Scheme Variable: resolver-event/found RR found, resolving successful. -- Scheme Variable: resolver-event/failure Resolving failed. In addition, browser and resolver call-backs are passed a list "lookup result flags" which is a list of values among the following: -- Scheme Variable: lookup-result-flag/cached This response originates from the cache. -- Scheme Variable: lookup-result-flag/wide-area This response originates from wide area DNS. -- Scheme Variable: lookup-result-flag/multicast This response originates from multicast DNS. -- Scheme Variable: lookup-result-flag/local This record/service resides on and was announced by the local host. Only available in service and record browsers and only on 'browser-event/new' events. -- Scheme Variable: lookup-result-flag/our-own This service belongs to the same local client as the browser object. Only available for service browsers and only on 'browser-event/new' events. This is useful for applications that both publish and browse services to distinguish between services published by the application itself and services published from other applications. -- Scheme Variable: lookup-result-flag/static The returned data has been defined statically by some configuration option.  File: guile-avahi.info, Node: Concept Index, Next: Procedure Index, Prev: API Reference, Up: Top Concept Index ************* [index] * Menu: * avahi-error: Error Handling. (line 6) * browsing: Service Browsing. (line 6) * bug reports: Introduction. (line 30) * constant: Enumerates and Constants. (line 6) * DNS-SD: Introduction. (line 6) * enumerate: Enumerates and Constants. (line 6) * errors: Error Handling. (line 6) * event loop: Core Interface. (line 6) * exceptions: Error Handling. (line 6) * mDNS: Introduction. (line 6) * poll: Core Interface. (line 6) * publication: Service Publication. (line 6) * resolution: Service Browsing. (line 6) * Zeroconf: Introduction. (line 6)  File: guile-avahi.info, Node: Procedure Index, Next: Variable Index, Prev: Concept Index, Up: Top Procedure Index *************** [index] * Menu: * add-entry-group-address!: Service Publication. (line 22) * add-entry-group-service!: Service Publication. (line 41) * add-entry-group-service-subtype!: Service Publication. (line 35) * address-resolver-client: Service Browsing. (line 145) * address-resolver?: Service Browsing. (line 178) * alternative-host-name: Service Publication. (line 16) * alternative-service-name: Service Publication. (line 10) * browser-event->string: Service Browsing. (line 172) * client-flag->string: Client Interface. (line 34) * client-host-fqdn: Client Interface. (line 12) * client-host-name: Client Interface. (line 16) * client-server-version: Client Interface. (line 19) * client-state: Client Interface. (line 9) * client-state->string: Client Interface. (line 37) * client?: Client Interface. (line 31) * commit-entry-group: Service Publication. (line 72) * domain-browser-client: Service Browsing. (line 160) * domain-browser-type->string: Service Browsing. (line 175) * domain-browser?: Service Browsing. (line 228) * entry-group-client: Service Publication. (line 60) * entry-group-empty?: Service Publication. (line 63) * entry-group-state: Service Publication. (line 66) * entry-group-state->string: Service Publication. (line 85) * entry-group?: Service Publication. (line 88) * error->string: Error Handling. (line 6) * error->string <1>: Core Interface. (line 132) * free-address-resolver!: Service Browsing. (line 185) * free-domain-browser!: Service Browsing. (line 235) * free-entry-group!: Service Publication. (line 95) * free-host-name-resolver!: Service Browsing. (line 195) * free-service-browser!: Service Browsing. (line 225) * free-service-resolver!: Service Browsing. (line 205) * free-service-type-browser!: Service Browsing. (line 215) * freed-address-resolver?: Service Browsing. (line 181) * freed-domain-browser?: Service Browsing. (line 231) * freed-entry-group?: Service Publication. (line 91) * freed-host-name-resolver?: Service Browsing. (line 191) * freed-service-browser?: Service Browsing. (line 221) * freed-service-resolver?: Service Browsing. (line 201) * freed-service-type-browser?: Service Browsing. (line 211) * guile-poll: Core Interface. (line 76) * guile-poll?: Core Interface. (line 114) * host-name-resolver-client: Service Browsing. (line 148) * host-name-resolver?: Service Browsing. (line 188) * interface->string: Core Interface. (line 123) * invoke-timeout: Core Interface. (line 166) * invoke-watch: Core Interface. (line 173) * iterate-simple-poll: Core Interface. (line 62) * lock-threaded-poll: Core Interface. (line 27) * lookup-flag->string: Service Browsing. (line 166) * lookup-result-flag->string: Service Browsing. (line 163) * make-address-resolver: Service Browsing. (line 28) * make-client: Client Interface. (line 23) * make-domain-browser: Service Browsing. (line 129) * make-entry-group: Service Publication. (line 76) * make-guile-poll: Core Interface. (line 79) * make-host-name-resolver: Service Browsing. (line 50) * make-service-browser: Service Browsing. (line 96) * make-service-resolver: Service Browsing. (line 71) * make-service-type-browser: Service Browsing. (line 113) * make-simple-poll: Core Interface. (line 72) * make-threaded-poll: Core Interface. (line 52) * poll?: Core Interface. (line 120) * protocol->string: Core Interface. (line 126) * publish-flag->string: Service Publication. (line 82) * quit-threaded-poll: Core Interface. (line 33) * reset-entry-group!: Service Publication. (line 69) * resolver-event->string: Service Browsing. (line 169) * run-simple-poll: Core Interface. (line 57) * service-browser-client: Service Browsing. (line 154) * service-browser?: Service Browsing. (line 218) * service-resolver-client: Service Browsing. (line 151) * service-resolver?: Service Browsing. (line 198) * service-type-browser-client: Service Browsing. (line 157) * service-type-browser?: Service Browsing. (line 208) * set-timeout-user-data!: Core Interface. (line 142) * set-watch-user-data!: Core Interface. (line 153) * simple-poll: Core Interface. (line 69) * simple-poll?: Core Interface. (line 117) * start-threaded-poll: Core Interface. (line 43) * stop-threaded-poll: Core Interface. (line 38) * threaded-poll: Core Interface. (line 49) * threaded-poll?: Core Interface. (line 111) * timeout-user-data: Core Interface. (line 145) * timeout-value: Core Interface. (line 148) * timeout?: Core Interface. (line 105) * unlock-threaded-poll: Core Interface. (line 24) * update-entry-group-service!: Service Publication. (line 30) * watch-event->string: Enumerates and Constants. (line 59) * watch-event->string <1>: Core Interface. (line 129) * watch-events: Core Interface. (line 159) * watch-fd: Core Interface. (line 163) * watch-user-data: Core Interface. (line 156) * watch?: Core Interface. (line 108)  File: guile-avahi.info, Node: Variable Index, Prev: Procedure Index, Up: Top Variable Index ************** [index] * Menu: * browser-event/all-for-now: Service Browsing. (line 251) * browser-event/cache-exhausted: Service Browsing. (line 247) * browser-event/failure: Service Browsing. (line 256) * browser-event/new: Service Browsing. (line 241) * browser-event/remove: Service Browsing. (line 244) * client-flag/ignore-user-config: Client Interface. (line 43) * client-flag/no-fail: Client Interface. (line 46) * client-state/s-registering: Enumerates and Constants. (line 38) * error/invalid-object: Explicit Finalization. (line 19) * error/no-daemon: Error Handling. (line 35) * lookup-flag/no-address: Service Browsing. (line 23) * lookup-flag/no-txt: Service Browsing. (line 20) * lookup-flag/use-multicast: Service Browsing. (line 17) * lookup-flag/use-wide-area: Service Browsing. (line 14) * lookup-result-flag/cached: Service Browsing. (line 268) * lookup-result-flag/local: Service Browsing. (line 277) * lookup-result-flag/multicast: Service Browsing. (line 274) * lookup-result-flag/our-own: Service Browsing. (line 282) * lookup-result-flag/static: Service Browsing. (line 291) * lookup-result-flag/wide-area: Service Browsing. (line 271) * publish-flag/allow-multiple: Service Publication. (line 112) * publish-flag/no-announce: Service Publication. (line 109) * publish-flag/no-cookie: Service Publication. (line 119) * publish-flag/no-probe: Service Publication. (line 105) * publish-flag/no-reverse: Service Publication. (line 116) * publish-flag/unique: Service Publication. (line 102) * publish-flag/update: Service Publication. (line 123) * publish-flag/use-multicast: Service Publication. (line 129) * publish-flag/use-wide-area: Service Publication. (line 126) * resolver-event/failure: Service Browsing. (line 262) * resolver-event/found: Service Browsing. (line 259) * watch-event/in: Enumerates and Constants. (line 59)  Tag Table: Node: Top969 Node: Introduction1620 Node: Conventions3357 Node: Enumerates and Constants3848 Node: Procedure Names6178 Node: Explicit Finalization6821 Node: Error Handling8818 Node: Examples10514 Node: Publishing a Service10887 Node: Browsing Published Services13590 Node: Resolving Services15626 Node: API Reference17610 Node: Core Interface18128 Node: Client Interface25942 Node: Service Publication27856 Node: Service Browsing33592 Node: Concept Index45712 Node: Procedure Index47023 Node: Variable Index54112  End Tag Table  Local Variables: coding: utf-8 End: