Sending Client Input to Server (which way?)

Hey!
I am trying to get networking working for my game, I’ve read several sources of information about this subject but one thing is still unclear for me.
The way I process client input is by executing a command bound to that input, for example:

Player presses D -> MoveLeftCommand gets executed which applies a linear impulse to the body of the player.

Since the server codebase and client codebase are almost the same I just reference the commands by bytes, MoveLeftCommand is for example byte 1.
What I have now is when the player presses D it sends the byte of the MoveLeftCommand to the server and the server executes this on the specified entity.
I don’t believe this is right though since the client will have to send 60 packets per second to the server just to move. It is no problem just send a JumpCommand, this command will get executed once. But I think there is another way to send position.
My question is: what is the common way to send input from a client to a server? I have read about ‘sanity checks’ on servers but I don’t now what is meant by that.
Thanks in advance!

I’m not that great for networking but here are two ways I would do it:

  • constantly send that command… Like really, what’s wrong with it? That’s only about 60 bytes per second… Although, if u are using TCP, this may cause problems as it will all get buffered up in a queue…

  • send a start command for when it starts and a stop command for when it stops… The only problem with this one is if u r using UDP… If u use UDP the stop command may not get along correctly and the user would get annoyed…

Again, I’m not that good at networking… But I would suggest the first idea with UDP…

Hope this helps…

First of all, sending update packets (like your move commands) is a really bad idea. Imagine multiple connected users that constantly send 60 packets per second, a lower frequency (8 for example) is much better because 60 packets are a very very big traffic for each connected client. In addiction you obviously need your server to process every incoming packet wich requires bandwidth, execution time and resources, you absolutely need to lower the number of packets sent per second.
Assuming you are developing something similar to an mmorpg game where many clients interacts thanks to the server (I guessed this type of game but correct me if I am wrong).
You need to implement client side prediction and interpolation because of this lower update frequency. Basically the client will calculate itself the new position when the move command is issued and when the server receives the update packet it send a confirmation packet to the client to tell that its movement was correct.
Here is a wonderful article about this: http://www.gabrielgambetta.com/fast_paced_multiplayer.html

About the sanity checks, I think that you mean the controls that the server must do on incoming data. For example, if a client send you movement packet while he can’t move because he is stucked on the ground by some strange mob, you need to verify it. Sanity checks are made to prevent player from cheating, you must never trust the users so these controls are very important.

I hope I answered your question.
-temu

ps: sorry for my bad English xD