Jump to content
  • Advertisement

Archived

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

exa_einstein

buffer

This topic is 5210 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

I have a simple question: What kind of buffer (what exactly) do you use when you code something like standart client-server game? I search for something fast and with a little more features than standart strstream (which is definitely NOT very usuable for multithreaded apps) do you think I''ll do the best when I code some buffer myself? OR does STL have something better (and fast)? helpme exa_einstein

Share this post


Link to post
Share on other sites
Advertisement
A buffer is, what, 50 lines of code?

You could use a std::vector but that would be mostly pointless. Just write your own buffer.

Also, if you know there''s a maximum packet size (say, 1536 bytes) then you should make all your buffers that size. Sure, it wastes a bit of data space for smaller packets, but you should re-cycle buffers after they''re done, rather than creating and destroying them at runtime.

And if someone sends a packet bigger than your maximum size, then you''ll only read the first N bytes, and because the size is bigger, you know it''s a bad packet and can discard it.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!