Hmmm…a thread about UDP vs TCP for games?
UDP!!!
Seriuosly though, it really depends on what you are writting.
For an action game you will of course want UDP because you will be operating in frame rates of 20-50 per seond to simulate real-time operations. Dropping a frame or two doesn’t really matter and if the network burps you can recover pretty fast. It also induces less overhead for the server because most action games are very heavy on server CPU because they have to make so many decisions on behalf of the clients. Remember in the action game world, it is usually users that run the server, not a server farm, so you need to think about “Joe shmoe’s” server (that may actually be running the client at the same time)…not the 200 PC’s with 2 processors sitting in the back room grazing on your OC-192 connection (read server farm here)
In an action game you can’t have the server waiting for a response in order to make a decision…if “Jane Ubber Boomer’s”’ packet didn’t arrive…Jane is out of luck…better to piss off one then many. If the packet arrives latter on, it doesn’t even matter because that 50ms frame is long gone anyways…client magic like bezier prediciton will have already solved it anyways. There is a reason why so many action games use UDP the requirements of an action game fit very well.
For something like an MMOG it’s really up to the developer. You can suffer the latency induced by guaranteed delivery becuase MMOG’s are typically round based and don’t require much server power at all (thus you can have crazy things like 10k on one box). This can be a benefit because if “Joe Wizard of Wilmouth” paid 75k GP for the fancy new cloak, you better be damn sure you got the message at the server or your CSR is gonna get an ear full With UDP you would have to force the client’s into requesting confirmations of such things which isn’t really good in todays MMOG environment simply because todays MMO clients are already overcomplicated with trying to render 200 players at once each with his unique and ubber goodies and customizations along with intricate/exahustive user interface…etc…and you have 10k other guys to worry about, double confirmation just doubled your servers work. MMOG’s focus is on distribution, supporting vast numbers of clients, accuracy of information not accuracy of state like an FPS. Instead of operating at 30 frames per second, you don’t need to think along those lines at all…the spell will reach the target if the roll was good…there is no collision detection for spells or sword swings…if there is in your MMOG (like Planetside) then your MMOG is really a monster scale action game and will have to go back to something like UDP or suffer with something you can not control …the users internet connection causing you a mega platinum in CSR costs
Bottom line: FPS = UDP… MMO = Whatever you fancy, but TCP is easiest.