Skip to main content
gamedev.net
🔒 Locked

buffer

Started by exa_einstein 0 replies 1k views
Original Post
exa_einstein
exa_einstein
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.
hplus0603
hplus0603
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 };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.