Announcing Mono.Zeroconf

I started working on Mono/.NET bindings to Bonjour/mDNSResponder almost two years ago. The code was quite useful but we found ourselves adding a lot of nasty preprocessor directives — yes, in C# — and configure junk to support both Mono.Zeroconf (Bonjour) and Avahi in software like daap-sharp and Banshee.

Earlier this year I found some time to start finishing my grand goal for Mono.Zeroconf — to support both Avahi and Bonjour through a simple, unified API.

Say what, exactly?

Today Mono.Zeroconf provides an easy to use API that covers the most common operations for mDNS (Browsing, Publishing, full TXT record support). It works either against Avahi (via the avahi-sharp bindings) or Bonjour on Linux, Windows, and Mac.

If your application needs to be cross platform (or even just cross-distro if you’re concerned about targeting older Linux distros) and perform Zeroconf networking, Mono.Zeroconf is the library for you. On Windows, the Mono.Zeroconf binaries work under both Mono and .NET.

It should be noted that Mono.Zeroconf does not support many of the more advanced mDNS features that Avahi in particular exposes. It is an intersection of the most common operations supported by both Bonjour and Avahi.

If your application needs advanced mDNS features, you most likely will care about the mDNS provider that you actually use (and I hope you choose Avahi). Therefore, I do not expect the functionality of Mono.Zeroconf to expand much and the current API is considered stable and complete. I may however add domain enumeration support in the future if it becomes a requested feature.

And how do I use it?

There are a couple of C# examples on the Mono.Zeroconf page that show how to browse, resolve, and publish services through Mono.Zeroconf. Here’s a quick adapted example on how to browse:

using Mono.Zeroconf;
ServiceBrowser browser = new ServiceBrowser ();
browser.ServiceAdded += delegate (object o, ServiceBrowseEventArgs args) {
    Console.WriteLine ("Found Service: {0}", args.Service.Name);
    // Connect to args.Service.Resolved event
    // Call args.Service.Resolve ()
browser.Browse ("_daap._tcp", "local");

There is also a small command line utility included in Mono.Zeroconf called mzclient. This works much like the traditional Bonjour command line tool, but it’s slightly nicer in ways I don’t remember. The source code to mzclient is probably the best example on what Mono.Zeroconf can do and how to do it.

Monodoc API documentation is also available.

Where is it?

Mono.Zeroconf will be part of the tarball set for the next Mono release (1.2.7). It is a separately maintained project and not bound to the Mono release schedule, but the upstream sources will be available in the same place. Packages will also be available through official Mono repositories.

For now, I have released sources on the Banshee web site. Packages (noarch) are available through the wonderful openSUSE Build Service for openSUSE Factory, 10.3, 10.2, 10.1; SLE 10; and Fedora 6, 7, and 8.

Sebastian Dröge is pushing it into Debian and Ubuntu, so packages should be available there soon. Will Farrington is working on a Conary recipe for Foresight.

Mono.Zeroconf is of course available in Mono SVN:

$ svn co