Page 1 of 1

Why doesn't uox3 receive packets at once ?

Posted: Tue Aug 14, 2012 7:14 am
by xantier
I don't know what is the disadvantage or advantage of this, but why not receiving the whole packet, then splitting it ? UOX3 does it differently, receiving the first byte, then second "length" WORD, then receives all. What happens if i change this and receive all the packet in the beginning with MAXBUFFER limitation ?

And by the way, why does Receive function uses a do..while at recv() ? Doesn't it already receive it when FD_ISSET successes ?

I want to learn these so i can implement an encryption system.

edit : aww it is weird to ask second question lol. WSAEWOULDBLOCK is the reason.

Re: Why doesn't uox3 receive packets at once ?

Posted: Mon Aug 20, 2012 3:26 am
by Xuri
Moved topic to coder forum.

I wish I could give you some of the answers you seek here, but my coding kung-fu is not good enough. The only (and pretty useless) answer I have is "because it's been like that for 10 years!", which obviously does not help in any way, form or shape. :P

Re: Why doesn't uox3 receive packets at once ?

Posted: Mon Aug 27, 2012 7:50 am
by Maarc
Yup, its because of blocking. If you request a read beyond what's been transmitted, it sits there and blocks the thread until it gets to a full buffer.

Given the single threaded nature of UOX, that makes no fun for anyone :)

Having said that, you'll generally find the packet is likely to be sitting in either hardware or Windows buffers, so its not the worst thing in the world. It's not a big delay, by and large.

FD_ISSET only indicates that there is an operation outstanding on the socket's FD of interest. It doesn't actually do any operation beyond telling you there's something to do.