//----- Include files --------------------------------------------------------- #include #include #include #include #include "network.hpp" //----- HTTP response messages ---------------------------------------------- #define OK_IMAGE "HTTP/1.0 200 OK\nContent-Type:image/gif\n\n" #define OK_TEXT "HTTP/1.0 200 OK\nContent-Type:text/html\n\n" #define NOTOK_404 "HTTP/1.0 404 Not Found\nContent-Type:text/html\n\n" #define MESS_404 "

FILE NOT FOUND

" int main(void) { std::vector> pending_futures; Server proxy(kProxyPort); Client browser; Client webserver; proxy.Open(); // Main loop to listen, accept, and then spin-off a thread to handle the GET while (1) { if (browser.ConnectFrom(proxy.socketFD) != 0) { std::cerr << "ERROR - Unable to create socket to client" << std::endl; continue; } if (webserver.ConnectTo(kWebserverPort) != 0) { std::cerr << "ERROR - Unable to connect to webserver" << std::endl; continue; } auto newThreadRequest = std::async(std::launch::async, HandleClient, browser.socketFD, webserver.socketFD); pending_futures.push_back(std::move(newThreadRequest)); } proxy.Close(); return 0; }