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

Author Topic: Sending Game Info Over UDP Is Very Slow  (Read 2307 times)

0 Members and 1 Guest are viewing this topic.

JacobHofer

  • Newbie
  • *
  • Posts: 4
    • View Profile
Sending Game Info Over UDP Is Very Slow
« 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!

JacobHofer

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Sending Game Info Over UDP Is Very Slow
« Reply #1 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!

 

anything