File: qtcpserver.cpp

package info (click to toggle)
qcoro 0.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,700 kB
  • sloc: cpp: 8,573; python: 32; xml: 26; makefile: 23; sh: 15
file content (14 lines) | stat: -rw-r--r-- 343 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <QCoroTcpServer>

QCoro::Task<> runServer(uint16_t port) {
    QTcpServer server;
    server.listen(QHostAddress::LocalHost, port);

    while (server.isListening()) {
        auto *socket = co_await qCoro(server).waitForNewConnection(10s);
        if (socket != nullptr) {
            newClientConnection(socket);
        }
    }
}