Server or Client Lagging?

edited April 2018 in Library Questions

I have a game and basically, the client will send its player location every draw loop, and the server will send it back (the server sends to all the clients). Then the client gets it back and says "if the player the server gave me isn't myself then use it. I have a problem because if I have one client joining the server the client will get the locations up to date but if I have two clients then all the sudden there will be lag and if I move the character the location will update like 10 seconds later. Does anyone know why this is happening and how to fix it? Thanks.

Answers

  • edited April 2018

    @RockyHawk -- this kind of problem is hard to diagnose without sharing actual code -- ideally an MCVE with a simplified version of the server and client code that demonstrates the problem.

    Also, why is this listed under Library Questions -- what library are you using for your client / server communication?

  • Alright, so I created an MCVE. I haven't done it before so it might be confusing but ill write below what to look for.

    The first client will count up and send that to the server, then the server will send it back with the IP in front of that number. The 2nd client will not count up every time because it will simply be creating the lag.

    You will notice the first client's console will have "Recieve:" and "Send:" They are self-explanatory. When you connect the 2nd client eventually you will see the first client will receive its own number and then the 2nd clients "0" but the 1st client's number will be delayed.

    https://github.com/rockyhawk64/Server-Client-Error

  • @RockyHawk Have you resolved this issue?

Sign In or Register to comment.