Question:
TCP or UDP?
Peter
2006-12-21 04:16:59 UTC
Hello, Whats the differences when making online games when using the UDP and TCP protocols?

Im using C++ and sockets.

- Cheers. Daniel
Six answers:
Danderson P. Maxwell
2006-12-21 04:24:16 UTC
Basically, when sending internet packets over TCP, when the packet reaches the target computer, the sender waits for the target to respond saying "Okay, I got this packet." before sending the next one along. UDP doesn't wait for this response.



As a result, packets sent via UDP protocol may arrive out of order, some may get lost on the way, etc. However, since there's no error checking, UDP is much faster than TCP.



Online games use a mixture of TCP and UDP. Commonly, UDP is used for things where its "okay" if they get lost, like player position and npc positions, etc. This is why you have noticable lag in the game...if packet A arrives and it says the player is at 1,1 and then packet C arrives saying he's at 2, 2 but then packet B arrives saying he's at 1, 2, well, you get the idea. This is acceptable by online game standards, because you can't wait for information like that, and it'll correct itself anyway when you get newer and newer packets.



TCP is used for data that you must get in its entirety. The Torque game engine (Tribes) uses something called "datablocks," which it sends at the start of every game as its loading. These contain information about all the objects and items in a game (for example, the mass of a car). This is sent via TCP as it is vital that the player has all this information.



Hope this helps!
?
2016-05-23 08:34:30 UTC
The TCP protocol exists on the Transport Layer of the OSI Model. The TCP protocol is a connection-oriented protocol which provides end-to-end reliability. By connection-oriented, we mean that before two network nodes can communicate using TCP, they must first complete a handshaking protocol to create a connection. When we say that TCP provides end-to-end reliability, we mean that TCP includes mechanisms for error detection and error correction between the source and the destination. These properties of TCP are in contrast to UDP, which is connectionless and unreliable. Higher layer protocols which utilize TCP include HTTP, SMTP, NNTP, FTP, telnet, SSH, and LDAP.
2006-12-21 04:21:54 UTC
TCP and UDP are internet protocols, a common language through which computers can communicate with each other.



TCP is a connection-oriented protocol, packets are acknowledged, is reliable and expensive. However, UDP is connectionless, faster and is not acknowledged.



If you are trying to make a game, or connect to one online, use UDP as it will give you faster performance.
kayrbabu
2006-12-21 04:25:32 UTC
TCP establishes a connection-oriented communication between two endpoints, and has error recovery built into it. Thus, you are always guaranteed that a byte sent from the source will arrive at the destination in the order it was sent. The latency can be quite variable. UDP, on the other hand, sends out a packet on the net, and there are no guarantees of any kind that the packet will reach the destination, ever.
2006-12-21 04:39:58 UTC
UDP doesn't care for accurate saving. It just wants to save faster.

Pros: Super fast.

Cons: Bad uploading/saving.

Pic: http://www.skullbox.net/udp.jpg



TCP is fast but the other computer slows it down, making it slow.

Pros: Accurate saving.

Cons: Very slow (some times 3-9 kbps, others 100-600 kbps depending on where the data is going).

Pic: http://www.skullbox.net/tcp.jpg
Elyess
2006-12-21 04:31:48 UTC
Hi,



either than making a long explanation here i would recommend you to read this :



http://www.laynetworks.com/Comparative%20analysis_TCP%20Vs%20UDP.htm



Virtually;


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...