[英]A non-blocking Poco HTTP server?
In Poco's documentation ( https://pocoproject.org/docs/Poco.Util.ServerApplication.html ) there is:在 Poco 的文档( https://pocoproject.org/docs/Poco.Util.ServerApplication.html )中有:
int main(int argc, char** argv)
{
MyServerApplication app;
return app.run(argc, argv);
}
This would imply a standalone, blocking server application.这意味着一个独立的、阻塞的服务器应用程序。 However, my use case is that I'd like to integrate a HTTP server to my already existing C++ application and it should not block the rest of the application.
但是,我的用例是我想将 HTTP 服务器集成到我现有的 C++ 应用程序中,并且它不应该阻止应用程序的其余部分。 Can I somehow just start the Poco server in its own thread?
我可以以某种方式在自己的线程中启动 Poco 服务器吗?
A ServerApplication
is meant to be its own Application
since it inherits from Application . ServerApplication
是它自己的Application
因为它继承自Application 。 This means it has its own main.这意味着它有自己的主。
So it depends on what you want to do in your ServerApplication
.所以这取决于你想在你的
ServerApplication
做什么。
If you want something else to be the main function, don't use ServerApplication
.如果您希望其他东西成为主要功能,请不要使用
ServerApplication
。 But if you want the benefits of option parsing and portable code, use ServerApplication
and have it spawn your other code via a thread similar to SampleServer .但是,如果您想要选项解析和可移植代码的好处,请使用
ServerApplication
并让它通过类似于SampleServer的线程生成您的其他代码。
I hope this helps.我希望这有帮助。
EDIT编辑
See HttpTimeServerApp参见HttpTimeServerApp
It has an example Application that contains an HTTPServer .它有一个包含HTTPServer的示例应用程序。 Maybe you just want an HTTPServer to start in your existing app.
也许您只想在现有应用程序中启动HTTPServer 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.