[ENet-discuss] enet_host_service in Thread

Peter Soxberger Peter.Soxberger at gmx.net
Sun Apr 19 02:38:25 PDT 2009


Hi!

I'm calling enet_host_service in a thread. For reducing the number of calls I added a Sleep(1000); in my loop. Now I noticed, that I could also use the internal timeout of enet_host_service(). It's even better I think. Because I can use a higher value like 10 seconds and events are still called immideately when data is received, but I reduced the calls in the thread (=> saved performance).


So my first code was like this:

while(enet_host_service(server,&event,0) != 0)
{
//....
Sleep(1000);
}

And now it's like this:

while(enet_host_service(server,&event,10000) != 0)
{
//...
}

Now I wanted to know if the second methode is really better or am I missing something? Does the second methode has any disadvantages?

I know that there is something in the tutorial about the timeout mechanism but it wasn't clear enough.

Thanks for your help!

Best regards,
Peter
-- 
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a


More information about the ENet-discuss mailing list