tags:

views:

57

answers:

2

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

I've investigated SIP (specifically Sofia and eXosip), but these tools exist as C libraries and are beyond my current ability to port them to the iPhone.

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

A: 

There is support for exactly this kind of ad-hoc peer-to-peer networking in GameKit. Have a look at the second half of the GameKit documentation for details:

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

Jake
Everything I've read about `GameKit` indicates that the peer-to-peer stuff only works over Bluetooth or local wireless, not over the Internet. But I'm not sure about that, of course.
MusiGenesis
+1  A: 

You're going to need a server that provides the match making service. Game Center makes this pretty easy, but your users will have to have Game Center accounts.

Alternatively, you can set up an XMPP (formerly Jabber, it's what powers Google Chat) server (I've never done this, but there are several available) and use the XMPP Framework for Cocoa. There are instructions for using it in iPhone apps here.

I'm sure there are other chat servers and client source also available. IRC and Mobile Colloquy come to mind.

Finally, you could write your own server using your favorite server language / framework. This isn't too hard (I've done it myself), but it's far from what I'd call simple, and I wouldn't use it for a production system.

Robot K
+1 great XMPP link - I love links with working code examples. Unfortunately, I'm actually trying to do SIP/RTP - I was focusing on chat first to get the network stuff worked out without having to worry about audio or video yet. Do you happen to have any helpful iPhone/VoIP links?
MusiGenesis
Also, thanks again for the XMPP link. XMPP will work perfectly for another aspect of this I have to write.
MusiGenesis
I looked at SIP briefly, but didn't get very far. It was a while ago, so there may be more out there now.
Robot K