I am looking for a way for clients in a LAN to find all the instances of my server application without any configuration. Instead of hacking something myself, I’d like to use an existing solution. Personally, I need it to be done in Python, but I’d happy to hear about solutions in any other language.
So why am I not using avahi or OpenSLP or some other Zeroconf/SLP solution? Well, there are a couple of additional criteria, and I’m under the impression neither of the aforementioned systems matches them.
I’m looking for a solution that is:
- Flexible. It must not require superuser rights, i.e. only use ports>1024.
- Solid. It must allow multiple services of the same and different service type on a single machine and continue advertising the services even when the instance that started the advertisement server stops or crashes.
- Portable. It must run nearly everywhere, or at least on *BSD, Debian/gentoo/RedHat/SuSe Linux, Mac OS X, Solaris and Windows NT.
- Light. Ideally, one Python script would be the whole solution. I’m not in the least interested in address autoconfiguration or something like that, although I’d begrudgingly accept a solution that has lots of features I don’t need. Furthermore, any one-time setup is a strict no-no.
I expect something like this:
def registerService(service): # (type, port) if listen(multicast, someport): if fork() == child: services = [service] for q in queriesToMe(): if q == DISCOVERY: answer(filter(q.criteria, services)) elif q == ADVERTISE and q.sender == "localhost": services.append(q.service) else: advertiseAt("localhost", service)
I wrote an application/library (currently Python and CLI interface) that matches all these critera. It’s called minusconf. Turns out forking is not even necessary.