UDP and TCP

Started by
4 comments, last by Xanather 11 years, 9 months ago
In fast-paced FPS game,
I plan to send updates stream from server to client using UDP.

Is it a good idea to send user actions from client to server using TCP ?
Or maybe it will be better to send this info using UDP and some delivery guarantee protocol ?
Advertisement
I'm no expert, but from what I understand so far, UDP with delivery guarantee is basically TCP.
So that would totally annihilate the advantage of UDP, which is, being faster than TCP.

I think in fast-paced games with constant updates for the gameview, TCP should only be used for requests which really need to get to their destination by all means, like, the Server has a list of clients which are currently playing and wants to add a new client. If you use UDP for that and the packet gets lost, you're screwed. Of course you could modifiy it so that your UDP socket sends that "connection request" over and over, until it gets a response from server which tells the client "yep, I got you". But as I said, that is basically TCP.

The thing with user actions is, user actions are most likely to be sent to the server all the time, so would it really hurt if there was some loss here and there? (which isn't even very likely to happen with UDP, it just CAN happen because there is no guarantee) using TCP for that constant flow of data would slow down the performance considerably and lags will become more likely.

At least, that's what I understand.
UDP with guaranteed delivery is not "basically TCP annihilating the advantage of UDP"... TCP is much more than that. TCP doesn't just guarantee delivery, it also guarantee's the packets to arrive in order, and it also manages flow of packets (flow control).

You should just use UDP. For an excellent resource explaining all the details, see: http://gafferongames...ers/udp-vs-tcp/
Oh I see, I wasn't aware of that particular difference between TCP and UDP, thank you.
http://www.gamedev.net/index.php?app=forums&module=forums&section=rules&f=15
For a FPS I would recommend using UDP, only because of the responsiveness that it provides and that it is a fast paced fps. By using UDP though you have to have ways to overcome packet loss (what if this is sensitive data such as a order to change map gets lost out in the vast internet?)

Read this, it talks about using lag compensation and other strategies in first person shooters (how valve's source engine does networking)
https://developer.va...ayer_Networking

I have never developed a mainstream network (especially for a FPS game) yet but I just know that reading that will be very helpful.

This topic is closed to new replies.

Advertisement