summaryrefslogtreecommitdiffstats
path: root/qtservice/examples/server/server.qdoc
blob: a73befbf792bac508e7be03a7e62b5dc762ceb4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// 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.
*/