Peer-to-peer network over wifi in iOS - ios

I've been at this for a few days now, and can't seem to find a solution. I want to create a peer to peer network over wifi on iOS. All open source code seems to be supporting running a server or being a client, but there's no code built to support being both - a peer. Is anybody aware of a way I can do this?

iOS 7 adds the Multipeer Connectivity Framework for exactly this purpose.

Have you thought of using Apple's GameKit framework? I've used it in the past for some simple communication between devices. It's really simple and can get you out of the gate quickly. This looks like a good tutorial.

I think Open Peer is the right solution. It provides real direct peer-to-peer connection between devices without the need of a centralised server. Check out this introductory video.

You cannot create a wi-fi network programmatically in iOS using current APIs. GameKit offers some APIs to do so over bluetooth however.
If you wish to implement a custom solution using CocoaHTTPServer, be aware that you will still not be able to create a direct wi-fi connection, you will simply be able to connect devices on the same (pre-existing) wi-fi network.
Ad-hoc peer to peer Wi-Fi (such as 802.11s) in iOS is still a few years off. Maybe iOSX ;)

iOS supports the Multipeer Connectivity framework which enables iOS devices to talk to each other over Bluetooth, infrastructure (with a router) WiFi, or P2P.
It does not, however, provide a way to explicitly use P2P. There is a layer of abstraction away from how any of a device's peers (other iOS devices) are connected, and it does not currently allow for non-iOS devices to be connected.

Related

Tcp connection between iOS devices

As for now, I'm using multi peer connectivity between iOS devices communication in same network. Facing major problem in connectivity, its getting disconnected often. So would like to move different approach.
Someone pls suggest me to achieve this in some other concepts.
You can solve your problem programmatically by detecting dropped connections and attempting to reconnect whenever a connection is unexpectedly lost. Some other considerations are:
Multipeer connectivity will not work when the app is running in the background
Multipeer connectivity tends to become unreliable if you are trying to maintain a connection between 6+ devices
If you are determined to find a replacement for Multipeer Connectivity, then we'd need to know more about what you're trying to accomplish. If you're trying to make a game, for example, I might suggest Google Play Game Services. You could also look into WebRTC.

Does iOS Multipeer connectivity work with non-smartphone devices?

Our guys in the field use equipment that have wifi and Bluetooth connectivity. One of our users has been using a non-iPhone (I guess Android) to transfer files between his phone and the equipment through Bluetooth. However, in switching our users to iPhones to use other enterprise apps we have discovered what some of you already know: iOS's Bluetooth connectivity is severely limited (i.e. no SPP protocol).
The equipment also communicates via wifi, so I was wondering if it's possible to create an app using iOS Multipeer connectivity to solve the Bluetooth problem. All I am finding about this, though, doesn't show anything but phone-to-phone multipeer connections, and not phone-to-machine multipeer connections.
At this point I know nothing about how the field equipment works; that's something I'll have to learn if we decide to pursue this. But assuming that it is capable of discovering wifi networks, would it be able to see the iPhone's network without needing any special software?
Or would I be wasting my time trying to figure this out?
Thanks!
If the equipment is using Bluetooth SPP then unless it is MFi certified you can pretty much forget about connecting to it from iOS. Multipeer connectivity won't do it, that's for sure.
WiFi may be a possibility - you need to get the iPhone and the equipment on the same WiFi network - you can't do this via an app though - you would need to use the WiFi settings in iOS - You will need to learn more about the equipment to see if that is possible.
Short answer: no. Only iOS 7.0+ or MacOS Yosemite+
MultipeerConnectivity is a framework for iOS and Mac OS. To send data using it, you need both devices to have iOS or MacOS with MultipeerConnectivity. You don't have any network-related parameters like "I prefer using bluetooth or wi-fi", it was designed to "just work out of box with simple goal - discover and connect other devices with MultipeerConnectivity.
It means that you can't send data from iPhone with MC to Android or Symbian or old iPhone with iOS <7 etc.
Before iOS7 you could use GameKit, but the logic is the same: both peers need to use GameKit.
If your custom equipment does not have iOS - you need to use lower-level API, and your options include generic Bonjour (NSNetService on iOS device and something Bonjour-compatible on custom device) or CoreBluetooth (obviously bluetooth-only, no wi-fi peer-to-peer) on the lowest level, using sockets and so on.

Multipeer Connectivity range and non ios device

I just started coding Multipeer connectivity with objective c in xcode. I have a few questions about the basics.
What is the range with Multipeer Connectivity? So if I make a chat program, will the two devices only be able to communicate if they are on the wifi network, or will they still be able to communicate if they are across the globe?
Will the program work with an ios device and a non ios device, so they can send each other messages? If yes, are there any extra methods or code that I need to add?
Thanks
As far as I understand MPC works over bluetooth and wifi- so if you are on a home wifi network, or a University campus network, your peers should be able to see one another. MPCis not for using across the globe that I know of...
This is an iOS technology only, iBeacon works across multiple platforms (iOS, android).
But, depending on what you want, you could make your app use internet to go across the globe, and you might be able to use straight bluetooth to connecto to a non-iOS device, then hook into MPC.
I would like to add to Keith's answer above that MPC supports peer-to-peer Wifi as well. This means that the devices involved don't need to be connected to an access point to talk to each other.
Also, the framework protects the developer (and end user) from the underlying technology (bluetooth, WIFI, P2P WIFI) used. In a given "session" between any number of devices (currently only up to 8 supported), each device could be using a different technology to talk to the others.

Connecting iOS a set of iOS devices with Wifi network

I'm searching a new way to sync data between iOS devices connected to the same Wi-fi network.
My app uses iCloud to sync its CoreData UIManagedDocument, but iCloud latency is too big for my goals.
Is there some way to connect iOS devices in the same Wi-Fi network with the iOS SDK? Any ideas?
Thanks
Any two IP-capable devices can connect to each other using BSD sockets - I've written an Objective-C wrapper to facilitate networking operations like this - here it is.
From iOS 7, you should look into the Multipeer Connectivity Framework. It allows connections between iOS devices on the same Wi-Fi network or Bluetooth personal area network, and the API is extremely simple to use.
You can use Gamekit to connect with both WiFi and Bluetooth and send data back and forth.
There's an excellent but lengthy tutorial here http://www.raywenderlich.com/12735/how-to-make-a-simple-playing-card-game-with-multiplayer-and-bluetooth-part-1
you should be able to pick out all the connectivity bits.

What is the mechanism used for having iOS devices communicate with each other?

Is is possible to have two iOS devices talk to each other without having a wireless network present?
If a network is required, can they communicate with each other without having a third device (a web server or something similar) to host the communication?
Yes, they can use Bluetooth or ad-hoc wireless network to the same effect. Apple in fact provides a framework designed to enable this: Game Kit.
See Apple's documentation on the subject for more information.

Resources