objc-obsessive
objc-obsessive

Reputation: 825

Bonjour networking (sending messages) to more than two iOS devices

I'm using example code from the answer on this Stack Overflow question (http://stackoverflow.com/questions/3240617/cfnetwork-and-bonjour-integration-for-iphone-to-mac-integration) which you can download here

I have the code running and I am able to send a message to the other device. Is there any way to link more than two devices to this network so that messages can be sent to specific devices in the device list at the same time?

Here's the plan for an app;

I want one admin version of the app which the admin user can send a message out to all the connected iPads (up to 12) in a list. Once they receive the message, they can reply to it and the admin user can see which iPad has sent the reply. How can this be done?

Upvotes: 0

Views: 4215

Answers (2)

objectiveccoder001
objectiveccoder001

Reputation: 3031

Not sure if I'm too late on this one, but check out Chatty. It's really really cool. I ported the iPhone app to Mac rather easily and set it as the server and the iPhone apps as clients.

I was using the code in the example app you posted at first, and was struggling to find out why it only allowed one connection. Thankfully, I was able to convert Chatty to my needs.

Upvotes: 0

Mugunth
Mugunth

Reputation: 14499

You should advertise two bonjour services, a server-service and a client-service. Servers should connect only to clients and clients should connect only to servers.

Bonjour is a service discovery protocol that makes the process of "knowing" peers in a network. This means, once you know the peer (server/client), you (and not Bonjour) have to establish the connection and from then on, it's up to your app to do what it wants to do.

Do note that, you have to remember the IP address of the clients you connect to (you get this information from the Bonjour service) and reconnect when the app awakes from sleep (iOS closes socket connections when the app enters the background.

Upvotes: 3

Related Questions