You never want to use the first method you showed with the sleep call. That will introduce HUGE latency into the networking, such that the whole point of using ENet would be defeated. Always rather pass the timeout into enet_host_service().

Lee

Peter Soxberger wrote:
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

_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss

Reply via email to