🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Dropping a TCP packet
With winsocks, if a recv is passed buffer that is not large enough, it will hold onto it data, fill the buffer, and return WSAEMSGSIZE.
What is the proper way to drop packets that are larger than expected?
Gamedev''s AI Auto-Reply bot.
Why would you drop a TCP packet in the first place? You could just call the receive function again to get the remainder, right?
cu,
Prefect
cu,
Prefect
You will _never_ get a WSAEMSGSIZE returned from recv() when using TCP. TCP has no concept of a message or message boundaries. It is a bytestream and nothing else. With UDP you could get a WSAEMSGSIZE in the situation you describe. But generally, it would be easier to just decide on some type of ''maximum'' message size, and always allocate buffers of that size.
I seem to remember something about aIs there not a semi standard maximum size of packet for most NICs (Network cards( of about 512 bytes...
But I could be wrong/crazy....
Convict@Large
But I could be wrong/crazy....
Convict@Large
Don''t take the subject of buffers too lightly....
Ever heard of buffer overruns? You don''t want to have holes in your network code, or someone will develop some kind of nuke, in case they are loosing....
Ever heard of buffer overruns? You don''t want to have holes in your network code, or someone will develop some kind of nuke, in case they are loosing....
No one is taking buffer overruns lightly. The point of the matter is that recv() only returns as much information as you tell it to via the "buffer size" parameter. You will not get a buffer overrun unless you mistakenly pass a value, that is larger than your buffer, to this parameter. Simple.
Dire Wolf
www.digitalfiends.com
Dire Wolf
www.digitalfiends.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement