Esempio n. 1
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();
	}
Esempio n. 2
0
	/*! Accept an inbound connection and obtain a connected socket
	  \param claddr location to store address of remote connection
	  \return the connected socket */
	Poco::Net::StreamSocket accept(Poco::Net::SocketAddress& claddr)
		{ return _server_sock->acceptConnection(claddr); }