enet
enet copied to clipboard
get network stats .
is there a way to get network stats like remaining packets in send queue or packet loss rate in enet.
just look up ENetPeer and ENetHost structs, you will find most of the things you will ever need there
@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 .
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
}
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; } }
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
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.
@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