Enet客户端在时间问题后自动断开连接

发布于 2024-10-11 17:06:22 字数 381 浏览 0 评论 0原文

所以我开始使用 Enet,我真的很喜欢它,但我正在做一些测试,从客户端向服务器发送信息(每秒 60 次),服务器成功接收这些数据包(每秒 60 次),一切进展顺利直到服务器随机停止接收数据包。

经过进一步测试,我发现客户端正在发送断开连接数据包,我不确定为什么。如果有人对 Enet 有任何了解可以帮助我,我将不胜感激。我目前唯一能想到的是客户端超时了。

好的,凌晨 4:30 是这个问题背后的解释。在我最后一个清醒的脑细胞中,我注意到一行代码的参数为 5000 毫秒,因为我每分钟调用我的代码 60 次,它在大约 30 秒左右超时,这是因为我有一行代码在错误的位置...吸取教训,午夜后不要在 stackoverflow 上发布问题...

  • 我不知道如何删除帖子,这有点无用

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 code 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁人与我共长歌 2024-10-18 17:06:22

我最近也遇到了这个问题,解决方案是两个主机(客户端和服务器)都需要定期调用enet_host_service,否则另一端会超时,就像发送了断开连接一样。

这是因为一些示例客户端/服务器代码不会在客户端中调用 enet_host_service

enet_host_service 进行一些内务处理,确保双方知道另一端还活着等等。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文