Mono.Zeroconf 0.7.4 and cross platform glory

I released Mono.Zeroconf 0.7.4 last night which is a minor bug fix release. Packages are available for openSUSE, SUSE Linux Enterprise, and Fedora. Sources and binaries are available for Linux, Windows and OS X.

What I have found interesting about Mono.Zeroconf is a growing adoption by the Windows crowd. I have been getting almost weekly emails from a new Windows developer using Mono.Zeroconf. A few bugs have been fixed in the process, though mostly in the Bonjour provider, which doesn’t affect modern Linux distros (because they use the Avahi provider, of course).

Since there’s been good feedback from the Windows world, I spent a little time making Mono.Zeroconf actually build on Windows in Visual Studio (yikes!). I am producing .zip files of the regular sources as well to make releases more accessible on Windows. Additionally, I generate a file which contains just pre-compiled assemblies.

The fun thing with all of this is validating how truly remarkable Mono is. I had never written any of Mono.Zeroconf specifically for Windows, never tested it on Windows, yet released the precompiled assemblies (built in Linux by Mono) for the hell of it. And without any changes, everything “just works” on Windows/.NET (and Mac OS X as well).

Andy made the leap to Linux.

So what’s so important about this? These new Mono.Zeroconf users on Windows inherit the fact that Mono.Zeroconf is truly cross platform, which means their applications are immediately more portable to Linux and other platforms that Mono supports. By luring Windows developers with delicious, easy to use libraries that are already cross platform, we make it easier and more enticing for those developers to bring their awesome applications to Linux.

Awesome. Mono rocks.

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