You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have enet_host_service with timeout 0ms on client and it seems eating my cpu alot compared to using 10ms. while (enet_host_service(client, &event, 0) > 0) {
using 10ms seems work, but not always because sometimes my client cant send packet anymore but still able to receive packet.
The text was updated successfully, but these errors were encountered:
@DevilLord41 actively polling socket with 0 timeout like this will always consume lot of CPU. It's best to combine with some higher level routines like select(2) or poll(2) so that you only call enet_host_service when you know the the underlying socket is readable - some data are waiting in the kernel to be read, or after you generate a packet to be sent, and eventually re-sent.
Logic I have come up with calls enet_host_service periodically to make sure outgoing packets, and pings are sent and re-sent as needed and fast enough, say 10 times per second, and then I call it immediately I am notified when data is available.
There is unfortunately no magic here, you have to do the plumbing...
Hi,
I have enet_host_service with timeout 0ms on client and it seems eating my cpu alot compared to using 10ms.
while (enet_host_service(client, &event, 0) > 0) {
using 10ms seems work, but not always because sometimes my client cant send packet anymore but still able to receive packet.
The text was updated successfully, but these errors were encountered: