TCP would've been easier to use (and in fact this project originally used TCP until I switched to UDP), but it is a very bad choice for most online games, since it sacrifices real-time responses for the sake of reliability and order.Mr. Guy wrote:Question: Why did you not use TCP? Is it more difficult or what?
UDP does not compensate for packet loss or disorganized data on its own, but I wrote the code in such a way that this doesn't matter much. Inputs are sent redundantly to the server, so if a packet is dropped, the same data will be sent in the next one. As for packets not arriving in the right order, the server will just discard any data that is not the most recent.