mi******@gmail.com wrote:
I'm trying to create a program that will buffer data received in UDP
packets.
I'd like to use an STL object that will allow me to add on new data
like this:
buffer+=newdata;
I don't think I can use a string because I don't think it allows 0
characters.
Any ideas on what to use?
If you use std::vector, pre-allocate the size for the average
packet. You don't want std::vector to reallocate while you
are receiving data.
Also, search the web for "double buffering". A minimum of
two buffers used for send and receiving.
Many embedded systems pre-allocate a space for the data
packets. These are arrays of unsigned chars. The goal
is to haul the data in as fast as possible, then analyze
it. An array has the minimal access times and least
overhead.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library