Show request_processor.cc syntax highlighted
#include <exception>
#include <string>
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <netxx/netxx.h>
#include <boost/thread.hpp>
#include "middleware.h"
using namespace std;
using namespace boost;
using namespace Middleware;
int main(int argc, char **argv)
{
if(argc < 2) {
cerr << "Pass port" << endl;
return 1;
}
Netxx::StreamServer server(atoi(argv[1]), Netxx::Timeout(0), 7);
Netxx::Peer client;
std::string line;
ThreadCleanup cleaner;
CleanupDelegate *c = new CleanupDelegate(&cleaner);
boost::thread cleaner_thread(*c);
delete c; // A copy was made by thread
while(client = server.accept_connection()) {
RequestProcessor p(client, &cleaner);
thread *t = new thread(p);
cerr << "Thread created at: " << (void*)t << endl;
cleaner.manage(p.getID(), t);
}
cleaner_thread.join();
return 0;
}
See more files for this project here