zeroconf

Homepage: https://www.gnu.org/software/emacs

Author: Michael Albinus

Summary

Service browser using Avahi

Commentary

This package provides an interface to the Avahi, the zeroconf
daemon under GNU/Linux.  The communication mean with Avahi is
D-Bus.

In order to activate this package, you must add the following code
into your .emacs:

  (require 'zeroconf)
  (zeroconf-init "dns-sd.org")

"dns-sd.org" is an example the domain you wish to resolve services
for.  It can also be nil or "", which means the default local
domain "local".

The `zeroconf-init' function installs several handlers, which are
activated by D-Bus signals sent from the Avahi daemon.
Immediately, when a service is added or removed in the domain, a
corresponding handler in Emacs is called.

Service Discovery
-----------------

The main purpose of zeroconf is service discovery.  This means,
that services are detected as soon as they appear or disappear in a
given domain.  A service is offered by a network device.  It is
assigned to a service type.

In order to see all offered service types of the initialized
domain, you can call

  (zeroconf-list-service-types)

Service types are described at .
Detected services for a given service type, let's say "_ipp._tcp",
are listed by

  (zeroconf-list-services "_ipp._tcp")

It is possible to register an own handler (function) to be called
when a service has been added or removed in the domain.  The
service type "_ipp._tcp" is used for printer services supporting
the Internet Printing Protocol.

  (defun my-add-printer (service)
    (message "Printer `%s' detected" (zeroconf-service-name service)))

  (defun my-remove-printer (service)
    (message "Printer `%s' removed" (zeroconf-service-name service)))

  (zeroconf-service-add-hook "_ipp._tcp" :new     'my-add-printer)
  (zeroconf-service-add-hook "_ipp._tcp" :removed 'my-remove-printer)

There are several functions returning information about a service,
see the doc string of `zeroconf-service-add-hook'.

Service Publishing
------------------

The function `zeroconf-publish-service' publishes a new service to
the Avahi daemon.  Although the domain, where to the service is
published, can be specified by this function, it is usually the
default domain "local" (also written as nil or "").

  (zeroconf-publish-service
   "Example service" ;; Service name.
   "_example._tcp"   ;; Service type.
   nil               ;; Default domain ("local").
   nil               ;; Default host (concat (getenv "HOST") ".local").
   111               ;; Port number of the host, the service is offered.
   "1.2.3.4"         ;; IPv4 address of the host.
   '("version=1.0"   ;; TXT fields describing the service.
     "abc=456"))

The lifetime of a published service is the lifetime of Emacs.

Dependencies

Reverse dependencies