开发者

Enet client automatically disconnecting after time issue

So I have started using Enet and I really like it but I was doing some testing sending information from a client to a server ( 60 times per second) and the server was successfully receiving these packets ( 60 times per second) and all was going well until randomly the server stops receiving packets.

After further testing I found out that the client is sending a disconnect packet, I am not sure why. If anyone has any knowledge of Enet that could help me out it would be greatly appreciated. Only thing I can currently think of is that the client is timing out.

Okay so 4:30 AM is the explanation behind this issue. With my last awake braincell I noticed a line of code with the an argument of 5000 ms, because I'm calling my code 60 times every minute and it was timing out at about 30 seconds or so it was because I had a line of cod开发者_运维知识库e in the wrong spot... Lesson learned, don't post questions on stackoverflow after midnight...

  • I'm not sure how to delete posts this was kind of useless


I ran into this problem recently too, and the solution is that both hosts (client and server) need to call enet_host_service regularly, otherwise the other end will time out as if a disconnect was sent.

This is because some sample client/server code floating around doesn't bother calling enet_host_service in the client.

enet_host_service does a bit of housekeeping, making sure that both sides are aware that the other end is alive and so on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜