C++ streams question (explanation of comment in code) -
i playing around fastcgi application found here.
the following comment in code:
if (content) delete []content; // if output streambufs had non-zero bufsizes , // constructed outside of accept loop (i.e. // destructor won't called here), // have flushed here.
my knowledge of c++ streams rather weak. please explain following:
- which streambufs being referred in comment?
- under conditions streambufs had non-zero bufsizes?
last not least, can point resource (pun intended) online provides clear gentle introduction c++ io streams?
which streambufs being referred in comment?
it's referring request.out
, part of reassigned cout
:
fcgx_request request; ... fcgi_streambuf cout_fcgi_streambuf(request.out); ... cout = &cout_fcgi_streambuf;
this reassignment means user can call
cout << "content-type: text/html\r\n" << ...
and have text show-up on either console (for testing) or across network when run cgi application. thus, 1 code sample can run in multiple environments.
under conditions streambufs had non-zero bufsizes?
the comment you're referring friendly reminder. fcgi_streambuf
objects in sample code constructed in loop; when loop ends, go out of scope , destructed.
the comment warns in many circumstances, user have flush output stream:
cout.flush ();
Comments
Post a Comment