Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What protocol is used to develop real time update games over the internet? From my research here is what I understood:

  1. You cant make one device (phone) as server to host room, you need real server not sure why.
  2. UDP have better performance but the data packet may get lost on the way
  3. TCP HTTP is the easiest way (what I am familiar with) my question here should I use REST and call the server each second from the clients(phones) to update game status or is there a way where the server can update the client?
share|improve this question
    
This is way too broad to be adequately answered. You don't want to use a phone as a host because a phone's internet connection is unreliable. If the host phone dropped offline, the game would most likely end. UDP is not desired for the same reasons. –  stephelton May 21 '12 at 7:15
add comment

3 Answers

First, don't try to reinvent the wheel. Take the idea of TCP or UDP and toss them out of the window. You will likely want to use HTTP with Android's standard URL calls.

As noted before, phones are a bad server. There isn't likely a case where X people are sitting around a table with phones connected to each other. They are likely in various places, doing various things. Phone signal strength varies greatly depending on a number of factors, but it is very likely that a phone will go to sleep or lose connection at some point.

What is the point of these real time updates? Real time on a mobile device is almost always bad. Real time requires almost a constant connection, which usually means a constant flow of network data, which eats up both network bandwidth limits and also will drain the phones battery. I suggest either using push notifications or polling at a reasonable rate (even better if this rate can be set by the user).

Android does support push notifications. These are useful to tell the phone that you have new updates, and then pull the appropriate data. This is where your REST server comes into play. The REST server gives you a central repository so that your game's data won't be lost. I commonly use two different android devices. Applications that sync my data between those devices are far more useful than those that do not.

share|improve this answer
add comment

I can suggest you to read this tutorial : http://gafferongames.com/networking-for-game-programmers/ It explains differences between TCP and UDP and provides an implementation of a UDP-like protocol used in games (in c++).

share|improve this answer
add comment

It's very difficult to get reliable peer-to-peer communication over the internet. It's much easier to use a central server as a relay among the clients. UDP accepts unreliable communications in exchange for better real-time behavior. It's possible to use two way pipes to exchange data freely, without polling, but also possible to use polled HTTP requests (or other methods) to periodically keep clients up to date. The best choice depends on what the required performance characteristics are, the number of clients, and the amount of data that has to move.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.