I'm working on an iPhone app that requires a basic client/server interaction model. For this I am going to use Bonjour and NSNetService, along with NSNetServiceBrowser to discover others on the same network. I have followed several different guides which more or less have the same sample code.
Relevant Server Code
...
serverName = [[UIDevice currentDevice] name];
netService = [[NSNetService alloc] initWithDomain:@"local."
type:@"_myservice._tcp."
name:serverName
port:port];
...
The service publishes successfully, i.e. I get the netServiceDidPublish: callback
Relevant Browser Code
...
browser = [[NSNetServiceBrowser alloc] init];
[browser setDelegate:delegate];
[browser searchForServicesOfType:@"_myservice._tcp."
inDomain:@"local."];
...
Now the result of all this is interesting:
Screenshot of iPhone Simulator
I'm sort of at a loss here... The simulator is working exactly as expected. However on the device it is not, I cannot get 2 different iPhones on the same WiFi to see each other, they only see themselves. Any idea what is going on here?
Turns out that the router that I'm on had an "SPI Firewall" enabled by default. Turning this off solved the problem.
One thing that I'm still curious about is: How come the requests coming from my Mac, both the iPhone Simulator and a Bonjour Browser, were able to get through this firewall but 3 different iPhones were not?