Jump to content
  • Advertisement

Archived

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

kurifu

Dropping a TCP packet

This topic is 5974 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!