[ENet-discuss] enet is dropping packets

James B z2895 at hotmail.com
Tue Jun 19 13:54:16 PDT 2012


why not just call enet_host_service with a timeout of 0, then if you haven't received any packets in X seconds do your own sleep(1) so you don't eat all the cpu.  also i don't know what platform you are on, but making enet sleep is not a wise choice IMO, for example on windows it uses timeGetTime which can be 5ms or more inaccurate, meaning you could only be processing the event loop 200 times per second rather than 1000 as you think.  what's worse in my testing is Sleep() and timegettime can be more inaccurate than that, sometimes sleep will sleep 5ms or 30ms, no matter the argument passed, which is why its much better to use an adaptive technique where you only sleep during times of low load, and where you control the sleep.  a good implementation might be to examine your current packets processed per second, and if this is under some value then sleep(1), if not then sleep(0)

----------------------------------------
> From: dreijer at echobit.net
> To: enet-discuss at cubik.org
> Date: Tue, 19 Jun 2012 15:30:14 -0500
> Subject: Re: [ENet-discuss] enet is dropping packets
>
> > Eh, it is an upper bound on the wait time if nothing is received!
>
> Are you absolutely sure about this? I seem to recall back when I started
> with enet that calling enet_host_service() with a high timeout would cause
> huge delays in receiving packets because enet_host_service() wouldn't return
> until the timeout has expired. I'll verify that again, but I thought that
> was how it worked at least.
>
> I find it hard to believe that my dedicated thread cannot service packets
> for 124 users (who aren't really sending THAT much data) if the thread is
> running as fast as it can.

 		 	   		  


More information about the ENet-discuss mailing list