// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause /*! \page qtservice-example-server.html \title A simple HTTP Server It is a very simple implementation of a HTTP daemon that listens on chosen port (defaultly 8080) and sends back a simple HTML page back for every GET request it gets. After sending the page, it closes the connection. \quotefromfile server/main.cpp \skipto HttpDaemon \printuntil }; The server implementation uses the QtService::logMessage() function to send messages and status reports to the system event log. The server also supports a paused state in which case incoming requests are ignored. The \c HttpService class subclasses QtService to implement the service functionality. \printto protected: The constructor calls the QtService constructor instantiated with QCoreApplication since our service will not use GUI. The first two parameters of our constructor are passed to QtService. The last parameter, "Qt HTTP Daemon", is the name of the service. \printto pause() The implementation of \c start() first checks if the user passed a port number. If yes that port is used by server to listen on. Otherwise default 8080 port is used. Then creates an instance of the HTTP server using operator new, passing the application object as the parent to ensure that the object gets destroyed. \printto private: \printuntil }; The implementations of pause() and resume() forward the request to the server object. \printuntil } The main entry point function creates the service object and uses the \c exec() function to execute the service. */