iPhone to iPhone communication

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.


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


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.

链接地址: http://www.djcxy.com/p/41944.html

上一篇: 如何用Thunderbird扩展插入电子邮件标题?

下一篇: iPhone到iPhone的通信