Advertisement Jump to content


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



This topic is 5366 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
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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!