Re: How to create an "endless" std::stringstream?
Hello,
Ziyan wrote:
I am writing a C/C++ program that runs in background (Linux).
Therefore, normally no output would be written into standard output.
However, sometimes I want to have debug message collected and sent tho
network to a client so that errors and debug messages can be displayed
simultaneously anywhere.
If anyone could give me some ideas about creating such debug streams,
or creating an endless stringstream, I will be very grateful. Thank
you.
The architecture of the iostreams library suggests to implement another
kind of stream buffer class to support streaming to destinations
different to files and strings, e.g. network sockets. AFAIR such
implementations have been mentioned here and in
comp.lang.c++.moderated. I think the network stream is a typical
example in books about iostreams. I think the book by Langer and Krefft
on C++ iostreams gives a lot of information, although it might be
dated. A lot of useful information on C++ iostreams has been given by
Dietmar K?hl.
If you look at the implementation of the string streams, which are using
a string buffer class, this should give ideas what to do to implement a
streambuf for network sockets. I think under Linux which probably means
g++ and libstdc++ there is already an implementation of a buffer class
available as an extension using a standard C file handle, which might
be immediately usable for network sockets.
Bernd Strieder