Prev: Newbie: Could use tutorial guidance of experienced TCP/IP sockets programmer
Next: ANN: dh, the daemon helper 2009-09-12 11:11
From: Ramon F Herrera on 12 Sep 2009 08:23 I have looked all over the net for this, but all the hits I get are about cout, cin or streams linked to disk files. The feature that I need is in-core (boy, that's an ancient term) streams and buffers. Back when I was a C programmer, I implemented my own streaming like this: char output_buffer[150 *1024]; char pointer = *output_buffer; pointer += sprintf(pointer, "text here %s\n", somevar1); pointer += sprintf(pointer, "more text here %s\n", somevar2); pointer += sprintf(pointer, "further stuff here %s\n", variable3); I then discovered something that looks exactly like what I need, but it is inside the Boost library. See snippet below. I bet that standard C++ and/or the STL must contain some facility that performs the functionality of the code below. TIA, -Ramon -------------------------- boost::asio::streambuf request; std::ostream request_stream(&request); request_stream << "GET " << argv[2] << " HTTP/1.0\r\n"; request_stream << "Host: " << argv[1] << "\r\n"; request_stream << "Accept: */*\r\n"; request_stream << "Connection: close\r\n\r\n"; // Send the request. boost::asio::write(socket, request); |