views:

2969

answers:

3

I'm kind of curious how I should approach a problem with iPhones and communication between two phones.

I have an idea for an application that needs to send data between two known phones. The problem is that the data could be very small or very large. I want to have intermediate storage on a server and a messaging layer, but I want there to be performant means to communicate between devices for shorter, unimportant messages.

You always hear about networking and client to client communication with popular platforms and protocols, but I'm curious what people's thoughts are on doing p2p style communication with an iPhone.

I'm pretty sure it should (and can) be treated as just a simple addressable machine... so I would have to build NAT traversing network code into the iPhone itself. A thought I had would be some sort of UPnP situation where I would ask to NAT a particular port for communication to the devices... but I guess I could just as easily turn it into a polling situation.

Granted, I understand that Apple will have a "push" mechanism for developers eventually but I want to get the app out the door before hand...

Just curious about thoughts on this type of thing... any thoughts on multi-player game situations would also directly apply to (and benefit from) this question.

+3  A: 

Have you given the WiTap sample from Apple a try? It addresses the issue of discoverability (via Bonjour) and connectivity (via basic TCP). It may not be as robust as what you are looking for, but it's worth a look:

http://developer.apple.com/iphone/library/samplecode/WiTap/index.html

Adam Byram
It's an OK example, was just curious about what people were thinking when it comes to device to device communication over the internet :)
whoisjake
+3  A: 

I'd hold up on this one. The 3.0 SDK has specifically addressed this. I'm going through the APIs soon, your problem should be a whole lot easier.

Rev316
A: 

Look at the docs for Game Kit in the iPhone 3.0 SDK. It allows iPhones to connect to one another locally with Bluetooth, or via wi-fi/3G. It addresses both peer-to-peer and client-server architectures. It provides unreliable and reliable links.

Kristopher Johnson