We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In KickoffTest.cc, a Tcpserver Object is created. I wanted to exit this server when there is no client connection. The following is my code:
int main() { /**** omit for same code ********/ .... server.setConnectionCallback([&n](const TcpConnectionPtr &connPtr) { if (connPtr->connected()) { ++n; if (n % 2 == 0) { connPtr->keepAlive(); } LOG_DEBUG << "New connection"; } else if (connPtr->disconnected()) { LOG_DEBUG << "connection disconnected"; /*** Begin: My Added Code****/ --n; if(n == 0) { loop.runInLoop([&server]() { server.stop(); }); } /*** End: My Added Code****/ } }); server.setIoLoopNum(3); server.start(); loop.loop(); }
My Added Code marked the codes that i added. And the server got stucked in line server.stop();.
My Added Code
server.stop();
How to solve it and how to exit a tcp server gracefully?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In KickoffTest.cc, a Tcpserver Object is created. I wanted to exit this server when there is no client connection. The following is my code:
My Added Code
marked the codes that i added. And the server got stucked in lineserver.stop();
.How to solve it and how to exit a tcp server gracefully?
The text was updated successfully, but these errors were encountered: