Thursday, May 14, 2015

networking - Client should send one big packet or multiple smaller ones per frame?


The client can do several actions per frame, for instance, requesting a movement, shooting etc. Should i send a packet to the server for each action the client performed during the frame, or should i stack them in an unique packet and send it at the end of the frame?


EDIT: i'm using Jmonkeyengine and the provided network API SpiderMonkey.



Answer



It shouldn't be a problem to send many packets in one frame. Every packet has some overhead, but you won't feel the difference.


However, if you decide to send a packet every frame, even if there was no user action (or the action is holding a key), while your client will work just fine, and your local testing server will do the job as well, real server will be easily flooded if multiply clients send multiply packets, multiply times (30, 60 or even more) a second. This is same if you want to update mouse cursor position on server every time a user moves the mouse.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...