tags:

views:

66

answers:

2

Hello, I was wondering is there an easy way to communicate between iphones over the Internet(Not LAN/Bluetooth) or must there be a dedicated server in which all the iphones running an application needs to connect to?

For instance, suppose I'm writing a game which works on the Internet. Once four clients joins a room, game starts. must I implement a server in which every Iphone client connects to (for instance if server was developed on Windows it could be a Service) or is there another way to address this when developing Internet-based application?

Thank you

A: 

You'd at the very least need some sort of central match making service so that the iPhones would be able to find each other, which would require some sort of dedicated server.

Secondly, devices on the internet can't always simply do a direct connection with each other. If all of the devices are behind a NAT or a firewall that doesn't allow incoming connections, you'd need a central dedicated server to host the game on. If at least one of the iPhones can accept incoming direct connections, you could have that iPhone host the game for the others.

There are some ways to punch through a NAT, but they're generally pretty horrifying in their complexity, and you'd still need the central match making service to pair up players.

Kitsune
thank you for your reply.one thing I want to be sure about is the difference between a central server and direct connection with iphones behind NATs. When a dedicated server manages the connection between clients, it simplify the need for port forwarding, however still having the issue with firewall. When iphones needs to talk with each other each iphone that wants to initiate a connection actually needs to allow port forwarding because he is a server behihnd a NAT, and of course firewall will be a issue too.Am I correct about port-forwarding issue?Thanks!
kernix
A: 

We have an online game that uses the iPhone (see www.ownthisworld.com if you want an idea of what we have done). Basically we use a php back end that accepts requests and returns xml data to the phone. It works quite well, but it depends on how much data you would be sending and your expected response times. In any event, our architecture of PHP/MySql backend works fine for our needs. By using the normal internet route, you do not have to worry about firewalls so much either.

Codezy
few questions:1. you didn't write another server, just added php pages for your site, correct?2. what's the difference between this and a webservice?3.In your architecture the server is based on http meaning that you can use sessions but you can't do bidirectional communication with the clients - how to you update them or they need to do a periodic queries on the web, for instance to know which players have left the game? 4.also, how to you address authentication, via Sessions or by passing each call user+password?thank you very much!
kernix
1. Yes just added php pages to the site. 2. It is essentially the same as a web service. 3. No bidirectional, the server can't send the clients messages, rather the clients have to poll the server for things of interest. For example you could have it poll the server every x seconds and have the server send events of interest, and the iPhone client parses and handles those events. Definitely relies on polling though.
Codezy