#include #include #include #include "tcpserver.h" #include "cbi_help.h" #include "cbi_pingpong.h" #include "cbi_quit.h" #include "cbi_recvfile.h" #include "cbi_sendfile.h" #include "cbi_shutdown.h" #include "workerbase.h" int main(int argc, char **argv) { NGL::NGLLoggerBootstrap::createNGLRootLogger("tcpserver_test.props", false); QCoreApplication app(argc, argv); QSettings settings(QLatin1String("./settings.ini"), QSettings::IniFormat); unsigned int port = settings.value(QLatin1String("port"), 4711).toInt(); TcpServer::registerCommand(port, CommandInterface::factory); TcpServer::registerCommand(port, CommandInterface::factory); TcpServer::registerCommand(port, CommandInterface::factory); TcpServer::registerCommand(port, CommandInterface::factory); TcpServer::registerCommand(port, CommandInterface::factory); TcpServer::registerCommand(port, CommandInterface::factory); TcpServer *tcpServer = TcpServer::instance(port); tcpServer->setUseWorkerThreads(true); if (!tcpServer->listen(QHostAddress::LocalHost)) { qFatal("Error listening on port %d, error: %d", port, tcpServer->serverError()); delete tcpServer; return 1; } QObject::connect(tcpServer, &TcpServer::destroyed, &app, &QCoreApplication::quit); int ret = app.exec(); return ret; }