SFML community forums
Help => Network => Topic started by: eggw on December 01, 2018, 10:04:11 am
-
I was experiencing some issues in my current project with latency delays while testing locally. Then I came upon this thread, specifically this message:
https://en.sfml-dev.org/forums/index.php?topic=12011.msg91201#msg91201
Changing my if's to while's fixed it. I was just wondering why it made such a huge difference. Is this a bug, or is there an intentional reason/explanation for why this occurs?
Thanks!
-
Do you understand what the change does?
How does it change your application's flow?
-
That's why I created this topic ;)
I'm currently using both a mixture of TCP and UDP sockets for a personal project (TCP only for the few, occasional packets I send that need to be guaranteed to arrive, UDP for position updates) . I'm using both in non-blocking mode, so I'm not sure exactly what effect the change really had. It didn't change any other behaviour; all that happened was that the delays vanished. Sorry if I'm missing something simple, this is my first foray in network programming.
-
With 'if' you only process one packet. If there are several waiting (in the system buffer) then they'll have to wait until the next few iterations of your game loop -- yes, this is latency ;)
-
With 'if' you only process one packet. If there are several waiting (in the system buffer) then they'll have to wait until the next few iterations of your game loop -- yes, this is latency ;)
Thank you very much, that clears things up! ;D
As a follow-up question, I just noticed something odd (not sure if this goes beyond the scope of SFML). I'm currently testing my networked program by running two instances of it, one which hosts and connects to itself via LocalHost in the same process, and the second which connects to the first via LocalHost as well.
Things appear to work when I test things with two instances of the GCC-compiled executables. However, when I try it with two MSVC-compiled executables, there is a significant delay in the packet sending. Interestingly enough, it also works if I try a MSVC host and a GCC client, but the other way around still lags. It's the exact same code, so I'm assuming MSVC is doing something non-standard. Are there any known quirks that would explain the discrepancy in behaviour between these two executables?
Edit: nevermind, I have found the issue. Thank you again for your time!