# Sending Client Input to Server (which way?)

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. Should I do something with client time?

• As a note, you don't have to send the absolute time. Both sides of the connection should be continuously measuring the current RTT of the connection. The outgoing packet can record the delta between when a message was generated and when the packet was actually sent. You can determine when a message was generated in the recipient's time by taking the ReceivedTime - RTT/2 - SendTimeDelta. There's no need to record time of packet sent, only when the message in the packet was generated, and only if there's considerable delay between the two (otherwise SendTimeDelta approaches 0). – Sean Middleditch Dec 16 '14 at 8:40