Пример #1
0
wdmSystem::wdmSystem()
    : m_end_flag(false)
    , m_root(NULL)
    , m_server(NULL)
{
    s_inst = this;
    m_conf.load((std::string(GetCurrentModuleDirectory())+"wdmConfig.txt").c_str());
    m_root = new wdmNodeBase();

#ifndef wdmDisableEnumMemberVariables
    ::SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG);
    ::SymInitialize(::GetCurrentProcess(), NULL, TRUE);
#endif // wdmDisableEnumMemberVariables


	if (!m_server && !m_conf.disabled) {
        Poco::Net::HTTPServerParams* params = new Poco::Net::HTTPServerParams;
        params->setMaxQueued(m_conf.max_queue);
        params->setMaxThreads(m_conf.max_threads);
        params->setThreadIdleTime(Poco::Timespan(3, 0));

        try {
            Poco::Net::ServerSocket svs(m_conf.port);
            m_server = new Poco::Net::HTTPServer(new wdmRequestHandlerFactory(), svs, params);
            m_server->start();
        }
        catch(Poco::IOException &) {
        }
    }
}
Пример #2
0
int main(int argc, char** argv) {

  Poco::Net::HTTPServerParams* pParams =
    new Poco::Net::HTTPServerParams;
  pParams->setMaxQueued(100);
  pParams->setMaxThreads(16);

  // do tcp bind and listen
  Poco::Net::ServerSocket srs(8080);

  // register client handler factory
  Poco::Net::HTTPServer srv
    (new MyHTTPRequestHandlerFactory, srs, pParams);

  // Start TCP server
  srv.start();

  // wait forever
  while (1) { sleep(1); }

  // Stop the TCP Server
  srv.stop();

  return 0;
}
Пример #3
0
void start_http_proxy(int port, int timeout, int threads, const std::string &url, bool verbose) {
    Poco::Net::HTTPServerParams *params = new Poco::Net::HTTPServerParams();
    params->setMaxQueued(50 * threads);
    params->setMaxThreads(threads);
    Poco::Net::ServerSocket sock(port);
    Poco::Net::HTTPServer server(new RESTHandlerFactory(timeout, url, verbose), sock, params);
    server.start();
    pause();
    server.stop();
}
Пример #4
0
	void subsystem::initialize(Poco::Util::Application& app)
	{
		webcpp::conf serverConf(app.config());
		Poco::Net::HTTPServerParams* pars = new Poco::Net::HTTPServerParams;
		pars->setMaxQueued(serverConf.getInt("maxQueued", 1024));
		pars->setMaxThreads(serverConf.getInt("maxThreads", 2048));
		pars->setSoftwareVersion(serverConf.getString("softwareVersion", "webcppd/1.0.0"));
		pars->setKeepAlive(serverConf.getBool("keepAlive", true));
		pars->setMaxKeepAliveRequests(serverConf.getInt("maxKeepAliveRequests", 0));
		pars->setKeepAliveTimeout(Poco::Timespan(serverConf.getInt("keepAliveTimeout", 60), 0));
		pars->setTimeout(Poco::Timespan(serverConf.getInt("timeout", 60), 0));

		Poco::ThreadPool &pool = Poco::ThreadPool::defaultPool();
		pool.addCapacity(serverConf.getInt("maxThreads", 2048));

		Poco::Net::ServerSocket serverSocket;
		Poco::Net::IPAddress ipAddr(serverConf.getString("ip", "127.0.0.1"));
		Poco::Net::SocketAddress socketAddr(ipAddr, serverConf.getUInt("port", 8888));
		serverSocket.bind(socketAddr, false);
		serverSocket.listen(serverConf.getInt("maxQueued", 1024));
		serverSocket.acceptConnection();
		this->server = new Poco::Net::HTTPServer(new webcpp::factory(), pool, serverSocket, pars);
		this->server->start();
	}