示例#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 SoapServerInternal::Start()
{
	if (m_running)
	{
		assert(false);
		return;
	}

	Poco::Net::ServerSocket mex(m_mexPort);
	Poco::Net::ServerSocket svs(m_rpcPort);

	//Configure some server params.
	Poco::Net::TCPServerParams* pTcpParams = new Poco::Net::TCPServerParams();
	pTcpParams->setMaxThreads(16);
	pTcpParams->setMaxQueued(1);

	Poco::Net::HTTPServerParams* pHttpParams = new Poco::Net::HTTPServerParams;
	pHttpParams->setMaxThreads(4);

	//Create your server
	
	m_soapTcpServer = shared_ptr<Poco::Net::TCPServer>(new Poco::Net::TCPServer(new TCPServerConnectionFactorySoap(this), svs, pTcpParams));
	m_mexHttpServer = shared_ptr<Poco::Net::HTTPServer>(new Poco::Net::HTTPServer(new MexHTTPRequestHandlerFactory(m_wsdlPath), mex, pHttpParams));

	m_soapTcpServer->start();
	m_mexHttpServer->start();

	m_running = true;
}
示例#4
0
文件: http.cpp 项目: ruslanec/waha
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();
}
示例#5
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();
	}