SFML community forums

Help => Network => Topic started by: JacobHofer on August 05, 2018, 10:01:28 pm

Title: Sending Game Info Over UDP Is Very Slow
Post by: JacobHofer on August 05, 2018, 10:01:28 pm
Hey everyone! So, I am new to the networking side of SFML, so to practice, I created a simple game. Basically users join and each control a square that moves around the screen. So far, it works fine, but sending and receiving data is very slow. Inputs take 1-2 seconds to register from one computer to another. Any ideas as to how I could fix it? Code is available below:

CLIENT CODE: https://hastebin.com/oviqiwajev.php
SERVER CODE: https://hastebin.com/xomolokabi.cpp

Thanks!
Title: Re: Sending Game Info Over UDP Is Very Slow
Post by: JacobHofer on August 08, 2018, 09:16:29 pm
After a few days of trying different things, I finally found a solution! Basically, the info was being sent as quickly as the computer could, which would leave my internet trying to play catch up with sending the info. So I basically ran 2 threads, 1 for receiving info (which was still on a loop as fast as possible to ensure no loss of data), and the other for sending data, which I sleep to make the data only send 20 times a second!