Can I use Bonjour from command line?

前端 未结 3 1773
野趣味
野趣味 2020-12-28 18:54

Is it possible to use Bonjour from command line? For example if I want to register a service I type something like that: bonjour -register service_name port. And then Bonjou

相关标签:
3条回答
  • 2020-12-28 19:19

    Yes, it is certainly possible. Take a look at the man page for mDNS

    0 讨论(0)
  • 2020-12-28 19:34

    dns-sd is the command line program that works on both windows and Mac OS X.

    I often use it to tunnel iTunes shares over the internet with ssh. My typical use is dns-sd -P my_music _daap._tcp. local 3690 localhost 127.0.0.1. This assumes that I've set up an ssh tunnel listen on localhost port 3690 to port 3689 of the host sharing iTunes on the foreign network. This makes a little iTunes share icon appear in iTunes named "my_music".

    0 讨论(0)
  • 2020-12-28 19:34

    mDNS is an older version of the dns-sd tool. They are both command line tools, written by Apple, to interact with Bonjour.

    You can use the command line tool to do a few things with Bonjour, but to quote from the dns-sd man page:

    The dns-sd command is primarily intended for interactive use. Because its command-line arguments and output format are subject to change, invoking it from a shell script will generally be fragile.

    If you wish to perform DNS Service Discovery operations from a scripting language, then the best way to do this is not to execute the dns-sd command and then attempt to decipher the textual output, but instead to directly call the DNS-SD APIs using a binding for your chosen language.

    For example, if you are programming in Ruby, then you can directly call DNS-SD APIs using the dnssd package documented at http://rubyforge.org/projects/dnssd/. Similar bindings for other languages are also in development.

    For example, you asked about "DNSServiceRegister", which is a C function:
    http://developer.apple.com/library/mac/#documentation/Networking/Reference/DNSServiceDiscovery_CRef/dns_sd_h/index.html#//apple_ref/c/func/DNSServiceRegister

    0 讨论(0)
提交回复
热议问题