UDP 锁定?
嘿伙计们,我需要人们猜测解决方案:(。
我正在使用 UDP 套接字,我正在做的是发送大约 8、4 或任何字节的玩家输入。我正在使用 recvfrom 和 sendto。它工作几分钟,然后随机它这可能是因为我的应用程序逻辑,但我想知道是否有人有这方面的经验,这是一个 UDP/网络问题。 org/486583" rel="nofollow noreferrer">http://www.pastie.org/486583 但我主要想知道根据您的经验我可以研究什么来纠正这个问题。
Hey guys i need people to guess the solution :(.
I am using UDP sockets and what i am doing is sending player input which is about 8, 4 or whatever bytes. I am using recvfrom and sendto. It works for minutes then randomly it will lock up. This could however be because of my app logic but i want to know if anyone have experience with this and it being a UDP/Networking problem. My code is here http://www.pastie.org/486583 but i mostly want to know what i can look into to correct this problem based on your experiences.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 Wireshark 找出哪一侧出现故障。
难道是发件人没有发件吗?
还是接收方没有接收到?
Use Wireshark to figure out which side is failing.
Is it the sender not sending?
Or is it the receiver not receiving?
您的 GetInput() 函数是否期望 sendTo 和 receiveFrom 始终完成? UDP 不保证发送或接收您的消息,也不保证消息到达的顺序。 我认为你的超时也设置为无穷大,所以每隔一段时间就会发生一条消息失败,而你无限期地等待一条已经丢失的消息。
Is your GetInput() function expecting sendTo and recvFrom to always complete? UDP is not guaranteed to send or receive your messages, or in what order the messages will arrive. I think your timeouts are also set to infinity, so what is happening is every once in a while, a message fails and you wait indefinitely for a message that is already lost.
“锁起来”是什么意思?
请注意,网络允许丢失(丢弃)UDP 数据包:您的协议应该允许偶尔丢失一些数据包,或者愿意重新传输。
What does "lock up" mean?
Note that the network is allowed to lose (drop) UDP packets: your protocol ought to allow some to be lost occasionally, or be willing to retransmit.
锁定是什么意思以及谁被锁定。
您还没有检查“recvfrom”和“recvfrom”的返回值。 “sendto”系统调用。 您是否尝试过运行 Wireshark 来观察行为。
What does locked up mean and who is getting locked up.
You have not checked the return values of "recvfrom" & "sendto" system calls. Have you tried running Wireshark to observe the behaviour.