How to make peer-to-peer communication in an application for iPhone?

I am trying to write a simple chat application for iPhone (as an experiment). Is there an easy way for the two devices to discover each other's IP addresses, and given the addresses, is there a simple API or protocol that will allow me to send text messages back and forth?

I researched SIP (in particular, Sofia and eXosip), but these tools exist as C libraries and do not correspond to my current abilities to transfer them to iPhone.

Update: I am trying to connect two devices via the Internet (i.e. not via Bluetooth or a local wireless network, which is what GameKit does).

+7
ios iphone sip
source share
4 answers

You will need a server that provides a mapping service. Game Center makes this pretty easy, but your users will have to have Game Center accounts.

Alternatively, you can configure XMPP (previously Jabber, this is what the Google Chat server supports) (I never did, but there are several available) and use the XMPP Framework for Cocoa . Instructions for use in iPhone applications are here .

I am sure there are other chat servers and client source. IRC and Mobile Colloquy come to mind.

Finally, you can write your own server using your favorite server language / framework. It is not too difficult (I did it myself), but it is far from what I would call simple, and I would not use it for a production system.

+5
source share

There is support for exactly this kind of peer-to-peer networks in GameKit. Take a look at the second half of the GameKit documentation:

http: //developer.apple.com/library/ios/#documentation / ...

+2
source share

NSNetService is a good option.

+1
source share

Take a look at the Datachannels websites . WebRTC is a newer option that supports native iOS support , which is still ending, but it is more flexible if the iOS application needs to interact with a browser or even android peers

+1
source share

All Articles