[ENet-discuss] enet_host_service in Thread
Philip Bennefall
philip at pbsoundscape.net
Sun Apr 19 05:29:49 PDT 2009
Also, if you use a timeout in ENet of 1000 and your thread has to do other
things as well, these will be delayed in the event that packets aren't
coming in all the time. If that thread has that one single task to perform
then its fine, but if you want to do other things as well (aside from
processing packets when they come in) then I'd recommend you setting the
timeout to a much lower value.
Regards
Philip Bennefall
----- Original Message -----
From: "Peter Soxberger" <Peter.Soxberger at gmx.net>
To: <enet-discuss at cubik.org>
Sent: Sunday, April 19, 2009 11:38 AM
Subject: [ENet-discuss] enet_host_service in Thread
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
_______________________________________________
ENet-discuss mailing list
ENet-discuss at cubik.org
http://lists.cubik.org/mailman/listinfo/enet-discuss
--------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.238 / Virus Database: 270.12.0/2066 - Release Date: 04/18/09
09:55:00
More information about the ENet-discuss
mailing list