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

Author Topic: Handle problems  (Read 2546 times)

0 Members and 1 Guest are viewing this topic.

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Handle problems
« on: April 27, 2013, 11:54:24 pm »
Hey guys, a friend of mine wants to know something, but I am not able to help him, and for some reason he cannot register in this forum right now, so he asked me to ask for him:


" Hello Community,
I am trying to programme a gameserver for a jump n' run. The problem is, that I really don't know how to handle the data transfer.
I am using TCP/IP and my server works so far in the following way:
-Listens to a given port(in my case: 12345)
-Accepts the incoming connection
-Creates a thread for each client(where the data is going to be received)

Questions:
Where and when should I send the data(e.g. player's position) to every client?
 -Where: in the client thread or another seperate thread(e.g. a worker thread for each client?)?
 -When: directly after the server has received it or after some time(because of the FPS rate?)?

Hopefully all of you guys could understand me!

greets ..."

Failing to succeed does not mean failing to progress!

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Handle problems
« Reply #1 on: April 30, 2013, 01:26:54 am »
Where and when should I send the data(e.g. player's position) to every client?

Since you're using TCP (which I think may be a mistake since your game has real-time movement...), I suggest sending positions every .1 second. If you want to trim down on this load, I suggest using some predictions within the clients to calculate where the most probable path for movement is (games like Fun Run, a mobile game, use this method, along with many others).

-Where: in the client thread or another seperate thread(e.g. a worker thread for each client?)?

I'm not sure what you're asking here. It's possible and suggested (in my opinion and experience) that you don't multi-thread the networking components, but it's entirely possible and sometimes practical to do so. Just make sure you understand and plan out your mutexes before hand.

Also, I can't tell if you want the clients to connect with other clients instead of a server. It is possible, but it's very insecure because of the lack of security with packet and client modding.




Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Handle problems
« Reply #2 on: May 05, 2013, 07:45:15 pm »
Thanks for your reply.
He says that now everything works like he wants ;)
Failing to succeed does not mean failing to progress!