Re: [GD-General] UDP questions
Brought to you by:
vexxed72
From: brian h. <bri...@py...> - 2002-06-30 20:17:36
|
> What are your sources? Well, my two sources are the following (via gamedev.net) and "everything else I've ever read" (i.e. Stevens, WinSock references, etc.). http://www.ecst.csuchico.edu/~beej/guide/net/html/advanced.html#sendall In the above, which is written in a fairly authoritative tone, there are a couple pieces that made it sound like you could receive packet fragments instead of entire packets. That's the part that confused me. Specific excerpts: "Likewise, when you're receiving this data, you need to do a bit of extra work. To be safe, you should assume that you might receive a partial packet....We need to call recv() over and over again until the packet is completely received. . . . Every time you recv() data, you'll feed it into the work buffer and check to see if the packet is complete. . . . Well, here's the second of the one-two punch: you might have read past the end of one packet and onto the next in a single recv() call. That is, you have a work buffer with one complete packet, and an incomplete part of the next packet!" Given the feedback from you and others, however, it looks either Beej's comments are wrong, or what he defines as a "packet" is something other than a UDP packet (e.g. his own packet structure, etc.) and thus possibly something that can become fragmented. From looking at it, though, it doesn't seem to be the case (i.e. the example he gives of a simple chat protocol shouldn't have a case where it fragments at the application level). Brian |