• Advertisement
Sign in to follow this  

UDP and TCP

This topic is 2036 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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: [url="http://gafferongames.com/networking-for-game-programmers/udp-vs-tcp/"]http://gafferongames...ers/udp-vs-tcp/[/url] Edited by btower

Share this post


Link to post
Share on other sites
Oh I see, I wasn't aware of that particular difference between TCP and UDP, thank you.

Share this post


Link to post
Share on other sites
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)
[url="https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking"]https://developer.va...ayer_Networking[/url]

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement