Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Making Sure Special Command Arrived  (Read 2062 times)

0 Members and 1 Guest are viewing this topic.

Strikerklm96

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Making Sure Special Command Arrived
« 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?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Making Sure Special Command Arrived
« Reply #1 on: January 22, 2015, 07:25:01 pm »
Yes. This is where you want TCP or you can use a library like ENet 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
AW: Making Sure Special Command Arrived
« Reply #2 on: January 22, 2015, 07:40:38 pm »
Quote from: Wikipedia UDP
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.
« Last Edit: January 22, 2015, 07:43:10 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/