buffer

Started by
0 comments, last by exa_einstein 19 years, 11 months ago
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
When I was younger, I used to solve problems with my AK-47. Times have changed. I must use something much more effective, killing, percise, pernicious, efficient, lethal and operative. C++ is my choice.
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.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement