UDP and TCP,
Members - Reputation: 670
Posted 22 June 2012 - 12:40 AM
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 ?
Members - Reputation: 216
Posted 22 June 2012 - 03:41 AM
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.
Members - Reputation: 1464
Posted 22 June 2012 - 04:07 AM
You should just use UDP. For an excellent resource explaining all the details, see: http://gafferongames...ers/udp-vs-tcp/
Edited by btower, 22 June 2012 - 04:07 AM.
Members - Reputation: 206
Posted 22 June 2012 - 07:03 AM
Members - Reputation: 776
Posted 23 June 2012 - 05:14 AM
Read this, it talks about using lag compensation and other strategies in first person shooters (how valve's source engine does 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.
Edited by Xanather, 23 June 2012 - 05:15 AM.