This is not a typical programming question, but I see it's a huge obstacle in testing your Bonjour based code.
Bonjour supports two mechanisms for servers to inform clients about their existence, multicasts on local network first, DNS second.
Multicasts are easy to use because there is no setup, unfortunately it can only be used on the same network.
DNS have the luxury of working across routers (Internet), but it requires properly configured nameserver and clients using that nameserver.
I think you are having only two options.
- advertise your bonjour service on WiFi network
- configure your own DNS
In the first case it is important to realize that the service doesn't necessarily have to be advertised by your own application running on a Mac. You can use utility dns-sd
to register any IP address/port as a Bonjour service on the network. For this to work you need a machine (Mac, Linux) which is connected to your WiFi, and run dns-sd
there in a similar way to this:
dns-sd -P "Stack Overflow" _http._tcp . 80 stackoverflow.com 69.59.196.211
This would register an "http" service with name "Stack Overflow" as a Bonjour service. Check it out - run it in terminal and check it in Safari's Bookmarks under Bonjour. The same way you can register your application.
Unfortunately you need to run this on a machine connected to WiFi network. That means your Mac application will advertise on its own ethernet network, dns-sd
advertises on WiFi.
Second option is a bit frightening, but it's not a big deal if you're willing to get hands dirty with some administration.
Again, you don't need to have services dynamically registered in DNS. You can simply hard code your Mac's name and your app's port in the DNS configuration. Those are just 4 lines that need to be added to the zone file (DNS configuration file).
b._dns-sd._udp IN PTR @ ; b = browse domain
lb._dns-sd._udp IN PTR @ ; lb = legacy browse domain
_icool._tcp PTR iCool\ App\ Service._http._tcp
iCool\ App\ Service._http._tcp SRV 0 0 8888 macpro.domain.com.
First two lines tells clients (iOS devices in your case) that Bonjour is enabled for this domain. Third line tells clients that there is a service "iCool App Service" of type icool
available. Fourth line tells clients current address and port of the service.
Clients will look for DNS entries for their configured (or gotten via DHCP) "Search Domains". Check your network settings.
You can run nameserver on your Mac, some Linux box, or you can use services like dyndns.com.
Hope this helps.