Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Connect multiple peers on the iPhone Application over WiFi?

I have an idea for an ios(iPhone) application to which requires connecting to several peers. I am basing my code on the WiTab (SampleCode-developer.apple.com) example.

When my application started each peer creating separate Socket(CFSocket) and publishing through NSNetService Class.In particular instance NSNetServiceBrowser class find available peers. And display their name in TableView.When i select row in the table view the corresponding peer address resolved, a connection established and sending-receiving data was successfully.

But my intention is ,I want to select multiple row in the tableView (multiple peer). and resolved selected peers address. For that I stored selected peers information to the NSMutableArray. When i click(touch) send button , I want to resolve Selected Device address and send data to selected peers. For that i did this code

 for(int k=0;k<[selectedService count];k++)
    {

             self.currentResolve = [self.selectedService objectAtIndex:k];         
             self.currentResolve = [self.selectedSer objectAtIndex:k];     
             [self.currentResolve setDelegate:self];    
             [self.currentResolve resolveWithTimeout:60];           
  }

But it will resolved only one device(self.selectedService objectAtIndex:0).So how can i resolved multiple peers Address/ how to established connection for multiple device. so my doubts are:-

  1. Is it possible to connect more than one device simultaneously over WiFi?
  2. If yes,What is the maximum number of device that can be connected in same pattern?
  3. Which type of CFSocket is useful for multiple Connection(TCP/UDP)?
  4. Is it required to create multiple CFSocket in each peer?
  5. If Yes,how? their is any documents available ?
  6. Is it required to established session?
  7. How to resolve address for mutple device?
like image 209
Musthafa P P Avatar asked Jan 18 '23 19:01

Musthafa P P


1 Answers

Its pretty hard to modify the Apple.Developer Witap application because you need to hold all the resolved adresses , have to modify all the methods and handle lot.

I think this tutorial will achieve your goal.

The app is called “Chatty.” Its source code is located here

Download the App --> Open --> Click-on Chatti project tab --> Build Settings --> Change the base SDK to iOS6

it is being released under the MIT license, which means that you are free to modify and reuse it at will

In this tutorial, They are going to explore a simple chat application for the iPhone. It allows you to host your own chat room and advertise it on your local Wi-Fi network (in which case your app acts as a chat “server”) or find and join chat rooms hosted by other people on your network (acting as a chat “client”). Both announcement and discovery of chat rooms are implemented using Apple’s Bonjour protocol same as Witap Application

Now I'm answering your each questions

Is it possible to connect more than one device simultaneously over WiFi?

YES, You can

If yes,What is the maximum number of device that can be connected in same pattern?

I think you can pair with any number of devices

Which type of CFSocket is useful for multiple Connection(TCP/UDP)?

My suggestion is TCP

The remaining answers for your questions can be easily understand from the sample Chatty App :)

Note: The server and clients need to be on the same WiFi network

like image 149
Shamsudheen TK Avatar answered Mar 04 '23 14:03

Shamsudheen TK