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
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement