Couple basic game network programming questions

Started by
3 comments, last by GameDev.net 18 years, 11 months ago
Is it ok to mix UDP and TCP in a game? For instance i'd like important things like messages, new players entering the area, admin commands, etc. to come in on TCP, and less important things like player updates coming in on UDP. The TCP traffic will be a lot less frequent than the UDP traffic. Seems like i've heard it's a bad idea to mix the two, but i'm wondering if that's still true if the TCP traffic would be pretty rare? My game is a space game, along the lines of Subspace, a live action arcade sort of game where it's fairly important you have a good idea of what other players are doing, what would be the best method to use to have smooth ships and bullets flying around? Dead reckoning? The Targetting method I found in the tutorials section here? Or something else? This will be on a "many clients one server" model. Should my network code on the client be in it's own thread, or will it be ok running in the main programs thread?
Advertisement
I've heard bad things about mixing UDP and TCP, because mixing the two causes jitter on the line which results in bad performance.

If I were you, i'd just use a reliable UDP API like RakNet.
FTA, my 2D futuristic action MMORPG
Just curious, where did you find the tutorial on the targetting method?
The Targetting tutorial is found here:

http://www.gamedev.net/reference/articles/article1370.asp


The main problem with TCP / UDP mixing is if you have logic that depends on both. If you're using them for completely seperate things you're largely OK.

The secondary problem is as referred to above: that badly configured routers will not correctly prioritize traffic.

IM recent E, most home routers are very well confiured out of the box, except some of the wireless ones. I've seen cheap ones from e.g. netgear with excellent telnet-rather-than-ftp style traffic shaping.

But, as you described your problem, there is nothing wrong with mixing them, since the uses are independent of each other. Then again, I'd follow the other opinion given above: if you're going to use UDP at all, use RakNet, eNet, or similar, and then you don't need UDP nor TCP at all, just let the library handle it, by running its proprietary code over UDP.

Note in particular that with UDP you MUST ASSUME that ALMOST EVERY SINGLE MESSAGE NEVER ARRIVES. If your game still works with that asusmption, fine. If not, then your game will not work. So, for instance, position updates will be OK so long as you can guarantee missed ones make no difference to your gameplay (if you only sent steering, rather than absolute position, this would not be true, but you'd get much much better speed and responsiveness)

redmilamber

This topic is closed to new replies.

Advertisement