SFML community forums

Help => Network => Topic started by: Strikerklm96 on January 22, 2015, 07:12:33 pm

Title: Making Sure Special Command Arrived
Post by: Strikerklm96 on January 22, 2015, 07:12:33 pm
In my game, when the Host hits "Launch", it sends data in a udp packet to each of the clients to let them know what level to load, and what entity they are in control of. How can I make sure they received it? Could I just send it several times? Is this where I would want to use TCP? Will packets ever be completely lost, or just delayed/out of order?
Title: Re: Making Sure Special Command Arrived
Post by: Jesper Juhl on January 22, 2015, 07:25:01 pm
Yes. This is where you want TCP or you can use a library like ENet (http://enet.bespin.org/) that builds a reliable channel on top of UDP.
Plain UDP does not provide guaranteed delivery and there is no way to determine if what you sent is recieved or lost. And yes, packets get lost completely and you will not be told about it. They also sometimes arrive out-of-order and more. The internet is a hostile network environment.
Title: AW: Making Sure Special Command Arrived
Post by: eXpl0it3r on January 22, 2015, 07:40:38 pm
Quote from: Wikipedia UDP (http://en.wikipedia.org/wiki/User_Datagram_Protocol)
There is no guarantee of delivery, ordering, or duplicate protection.
Might want to read up on the topics you're working with. ;)

Adding a reliable protocol on top of UDP (like Enet does) is only a good choice in very few cases.
If you want reliability, use TCP.