5 ms·
You could google how to do a simple fork server in c/c++ and after you have that working you just need to do something like this: stringstream response; resp
by BuckToBid 16y ago
You could google how to do a simple fork server in c/c++ and after you have that working you just need to do something like this:
stringstream response;
response << "HTTP/1.1 200 OK\r\n"
<< "Server: BTB Auction Updater 1.0\r\n"
<< "X-Powered-By:BTB Update Engine\r\n"
<< "Content-Length: " << msg.length() << "\r\n"
<< "Content-Type: text/html\r\n\r\n" << msg;
int n = write(s, response.str().c_str(), response.str().length());
if(n < 0) error("Error writing to socket");
to write back a valid header that a browser will understand
- chrisaycock 16y agoYou could store the static (non-changing) text in a couple of C strings and then call writev() to communicate everything. That would save you the step of continuously reconstructing the header.
- BuckToBid 16y agoThanks for the suggestion!