After the big Apple Leopard patch the other day, my HP printer
stopped working. I could still ping it, but my Mac wasn't sending
it print jobs, and that was that.
I don't automatically blame Apple for this. HP has a long, long
history of making everything too darn complicated. No doubt
companies of the same general size as HP appreciate all the extra
crud built into their software, but for me, just let me send data
to port 9100 and print it it - or not. On OS X 10.4, that's
just how I had set up this printer: something like :
But with Leopard, I had let the System Preferences Print & Fax tool
have a crack at it, and sure enough, it found the printer through
Bonjour, Apple's zero-conf networking discovery thingy. You can get Bonjour for
Windows and Linux; "mDNSResponder" (the core of Bonjour) is open
source. Although I have some reservations about dumbing everything
down, it is nice to have "chatty" machines and services. Or
at least it's nice when they work.
But when I returned
to System Preferences now, it still had the printer, yet I couldn't convince it
to send anything to actually be printed.
I thought I might try deleting the printer and adding it back.
Deleting seemed to work fine, but clicking on "+" to have it
find the printer again just gave me a spinning beach ball.. which never
went away.. so I finally rebooted, and after that Bonjour instantly
found my printer and I could print again.
All that made me curious about Bonjour. In scrounging about the Net,
the first thing I came across was this Rawr-jour, which certainly looked like it would be fun
to play with, but alas, it seems to have disappeared from our world.
Oh well. I pecked about a little more and found Net::Bonjour on CPAN. I did a quick
"sudo cpan" and then an "install Net::Bonjour" and then wrote this
little program, mostly cribbed from the author's example:
Why on earth did I list all those services? Well, for one thing, I
was curious as to what other Bonjourish things might be running, but
more directly, I had no idea what the HP had advertised. You see,
there is this big
list of DNS SRV (RFC 2782) Service Types and I have no idea
which one HP uses. I thought it might have been "ipp", and when that didn't
work I tried "printer", and when that came up dry I populated the list
as you see it above. That found the printer strutting its stuff
I don't even know why I stuck http in there, but there it was. The
printer is running a webserver. Now that isn't exactly thunderous
news: an awaful lot of devices do that nowadays, but there had been
nothing in the documentation I got with my printer that had
mentioned this, so it was just a little surprising. Sure
enough, a browser pointed at http://192.168.1.4 brought
up configuration stuff that I had to use a Windows CD for
when I bought the darn thing. How annoying that they didn't
say anything about that.
A Bonjour service of course doesn't have to be hardware. It
can be just about anything you can dream up, and I see great
possibilities for perversion. For example, what's stopping
you from implementing a print to fax service and letting the print
service discover it as a Bonjour "printer". More interesting is
what would stop you from implementing something far more deviant? Why,
nothing at all, and if you'd like a head start on that, MacDevCenter
has a couple of Mac posts about just that subject: