UDP and TCP

Blitz3D Forums/Blitz3D Beginners Area/UDP and TCP

BLaBZ(Posted 2009) [#1]
Are any games known to use both UDP and TCP connections?

Is this good or a bad practice?


jfk EO-11110(Posted 2009) [#2]
I Don't know any game that is using both, but I can't see why you shouldn't use both. Each protocol has its pros and cons. You could use UDP for a steady dataflow of Positions, Actions etc. and tcp for larger data bulks of eg. sounds, images, updates etc.

TCP does error-detection and correction by its own, where with UPD you have to do this by your own. So you should work with checksums, and when the checksum does not fit with the data, you have to reorder the packet. So, some kind of handshake would be useful: Packet ok! or Packet defective ,please resend! You may also index all UDP packets, so when you receive packet 123 and then 125 you'll be able to notice packet 124 was lost somewhere.

Needless to say, the more protocols, streams and ports are involved, the harder will it be to make it work together with all hubs, routers and esp. firewalls.


Matty(Posted 2009) [#3]
No problems using both. Ultimately you are just wanting to send information from one PC to one/many and you have the choice of
fast unreliable (UDP)
not-as-fast but reliable (UDP with your own checks for correct packet arrival etc)
100% reliable but variable/less predictabe speed (TCP)


AJ00200(Posted 2009) [#4]
If you have a constant stream of new UDP position data, would you need to check it?


Matty(Posted 2009) [#5]
What are you talking about? Would you need to check it? Check What?
UDP Packets are not guaranteed to reach their destination either at all or in order so when you do receive a UDP packet you may want to check if it is in order...very easy...and if it doesn't get there at all you may or may not need a system to handle that.


BLaBZ(Posted 2009) [#6]
I was thinking for lets say a first person shooter game, UDP for position updates, shots fired etc, and TCP for chat/communication.


_Skully(Posted 2009) [#7]
I would go UDP for anything in-game.. TCP to level loads and stuff like that... TCP will cause pauses as it waits for receipt packets... you dont want pauses in-game!


xtremegamr(Posted 2009) [#8]
When I was first learning to use the UDP functions in Blitz, I created a test UDP proggy that used both UDP and TCP. My server program used TCP to tell clients when a new player connected and disconnected, and UDP to send new player coordinates.


Wings(Posted 2009) [#9]
UDP is packed driven. packets arrive difirent. no saterfaction garanteed so you have to mark each packet self.

in FPS my guess is UDP.. you can send position every frame :)