Archived

This topic is now archived and is closed to further replies.

kurifu

Dropping a TCP packet

Recommended Posts

kurifu    122
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.

Share this post


Link to post
Share on other sites
Prefect    373
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

Share this post


Link to post
Share on other sites
JonStelly    127
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.

Share this post


Link to post
Share on other sites
Convict@Large    122
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

Share this post


Link to post
Share on other sites
Askadar    122
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....

Share this post


Link to post
Share on other sites
Dire.Wolf    122
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

Share this post


Link to post
Share on other sites