I would be interested in knowing which programs advertise themselves using Bonjour on my machine. Is there a way to do that?
Using that list, you can request information about the individual services types by running things like
To be honest, though, this whole process is rather tedious, and it's exactly what Bonjour Browser was built to do, so I highly recommend using that. (The app might be ancient, but it still works.) Whichever way you do it, though, it may not always be clear what program is responsible for a given service entry.
You can use the strategy given in binarybob's answer to try to map service entries to running processes based on port number, but this may not always work. Another strategy is to run something like
Although classified as a legacy article, this very may well be what you are looking for: DNSServiceMetaQuery. As outlined by the documentation:
To run DNSServiceMetaQuery on Mountain Lion (the included build does not run properly), go to the sample code link and click Download Sample Code. Then, install Xcode if you haven't already. Create a new project under the template of Mac OS X > Application > Command Line Tool.
Open and copy all text in
Although it might not satisfy your exact criteria, Tildesoft's Bonjour Browser can list all the all the bonjour services advertised on your local network and the hosts that are advertising them.
I guess for locally advertised services you could drill down in Bonjour Browser to find the port number the service is advertised on, then use
when I have iTunes running.