enet icon indicating copy to clipboard operation
enet copied to clipboard

get network stats .

Open peererror opened this issue 7 years ago • 7 comments

is there a way to get network stats like remaining packets in send queue or packet loss rate in enet.

peererror avatar Jan 12 '18 20:01 peererror

just look up ENetPeer and ENetHost structs, you will find most of the things you will ever need there

inlife avatar Jan 17 '18 08:01 inlife

@inlife Thank you for the response I can see ENetPeer has the information.
One more thing I am having an issue of peers stop receiving data after some time although i can see the peer states are connected and they can also send data to server .

peererror avatar Jan 17 '18 15:01 peererror

make sure you are constantly calling the enet_host_service method

ENetEvent event;
while (enet_host_service(host, &event, 100) > 0) {
    // your event handling code
}

inlife avatar Jan 17 '18 15:01 inlife

I am calling enet_host_service like this while (!dissconnect) { { Sleep(1); int res = enet_host_service(clientEnet, &eventEnet, 0); } switch (eventEnet.type) { case ENET_EVENT_TYPE_RECEIVE: handle_receive((size_t)eventEnet.packet->dataLength , (unsigned char*)eventEnet.packet->data); enet_packet_destroy(eventEnet.packet); break; case ENET_EVENT_TYPE_DISCONNECT: dissconnect = true; printf("DC from server \r\n"); break; default: break; } }

peererror avatar Jan 17 '18 15:01 peererror

i would suggest wrapping your enet_host_service into a one more cycle, just like i've shown above it will make sure you are retrieving most of the events that you have sent

inlife avatar Jan 17 '18 15:01 inlife

How long does Sleep(1) wait? You could instead just pass that duration as the timeout parameter to enet_host_service. Then you don't need another cycle.

bjorn avatar Jan 17 '18 21:01 bjorn

@inlife @bjorn I have tried both of your suggestions and now I am getting disconnected from server on peer after 2 mins . Do anyone know why is that ? is it due to packet lost ? Regards

peererror avatar Jan 18 '18 16:01 peererror