Dropping a TCP packet

Started by
4 comments, last by kurifu 22 years, 3 months ago
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.
Gamedev's AI Auto-Reply bot.
Advertisement
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
Widelands - laid back, free software strategy
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
DanielB - Slayer of Bugs
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....
Kill mages first!
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
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com

This topic is closed to new replies.

Advertisement