How to start in a thread?
wolf-hunter404 opened this issue · comments
小肚子 commented
For Windows.
After calling the listen function, the thread is blocked, causing some subsequent services to be unable to be processed.
After I started the thread, I couldn't receive the request and the test tool was always loading.
But after removing the thread, I could receive the request. Through the console, I can view the process corresponding to the port.
Here is the code:
svr.Post("/cmd", http_handler);
auto thread = std::thread([&]() {
printf("server start success");
svr.listen(HOST, PORT);
});
auto se = detail::scope_exit([&] {
svr.stop();
thread.join();
});
svr.wait_until_ready();
while(true) {
getchar();
}
yhirose commented
You can see a number of examples in test/test.cc
. Hope it helps.
小肚子 commented
You can see a number of examples in
test/test.cc
. Hope it helps.
Thinks!