开发者

what are the possible UDP data transfer errors?

we're going to develop a game with internet multiplayer support. since it's an interactive game I know I have to use UDP to reduce connection latency, but I'm wondering what are the possible errors that may occur in a package delivered using UDP connection? everywhere I looked they say UDP provides "Best effort delivery", but开发者_StackOverflow no one does give a complete explanation what does it mean. after reading some article there are two questions that I still have:

  1. Is it possible to send a package and receive part of it at the other end of connection?
  2. if your answer to first quesiton is true what would happen to the next packages? should I wait for the rest of package or can I assume next package start with my next recv call?

for our game I think we will need to send 4 packages of around 20 byte each second.


The most common thing that can happen is: one side sends a message, the other receives nothing.

Is it possible to send a package and receive part of it at the other end of connection?

Not really, not even when the message is huge and it gets fragmented. Unlike in TCP, in UDP every message is independent. You either get it entirely or nothing at all.

So what you should do it just recvfrom things in a loop and process them. Obviously you should make your application impervious to message loss such that a missing message doesn't crash it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜