Awesome Open Source
Awesome Open Source



QtNetworkgNg is a coroutine-based network toolkit. Compare to boost::asio and Qt's QtNetwork, QtNetworkNg has more simpler API which is similar to python-gevent. As the name suggests, QtNetworkNg requires Qt5 framework. For more detail visit:

Introduction to QtNetworkNg




  • General Coroutine with similar API to QThread.
  • Socket supports UDP and TCP.
  • SSLSocket with similar API to Socket.
  • KcpSocket implements KCP over UDP.
  • HttpSession implements a HTTP 1.0/1.1 client, supports connection via SOCKS5/HTTP proxy.
  • HttpServr implements a static HTTP 1.0/1.1 server, can be used for reversed http proxy.
  • MsgPackStream is a new MessagePack implementation similar to QDataStream
  • Cipher, MessageDigest, PublicKey, PrivateKey wrap complicate LibreSSL C API.


Here comes a simple example to get web pages.

#include "qtnetworkng.h"

int main(int argc, char **argv)
    qtng::HttpSession session;
    qtng::HttpResponse r = session.get("");
    qDebug() << r.html();
    return 0;

And another exmaple to make IPv4 tcp connection.

#include "qtnetworkng.h"

int main(int argc, char **argv)
    qtng::Socket conn;
    conn.connect("", 80);
    conn.sendall("GET / HTTP/1.0\r\n\r\n");
    qDebug() << conn.recv(1024 * 8);
    return 0;

To create IPv4 tcp server.

Socket s;
CoroutineGroup workers;
s.bind(HostAddress::Any, 8000);
while (true) {
    QSharedPointer<Socket> request(s.accept());
    if (request.isNull()) {
    workers.spawn([request] {

To create HTTP server is even more simpler:

TcpServer<SimpleHttpRequestHandler> httpd(HostAddress::LocalHost, 8000);

A Qt GUI example to fetch web page.

// main.cpp
#include <QApplication>
#include <QTextBrowser>
#include "qtnetworkng.h"

using namespace qtng;

class HtmlWindow: public QTextBrowser
    virtual ~HtmlWindow() override;
    CoroutineGroup *operations;

    :operations(new CoroutineGroup)
    operations->spawn([this] {
        HttpSession session;
        HttpResponse response = session.get("");
        if(response.isOk()) {
        } else {

    delete operations;

int main(int argc, char **argv)
    QApplication app(argc, argv);
    HtmlWindow w;;
    return startQtLoop(); // Qt GUI application start the eventloop using startQtLoop() instead of app.exec()

And its project file.

QT += widgets
SOURCES += main.cpp

As you can see, networking programming is done with very simple API.


The QtNetworkNg is distributed under LGPL 3.0 license.

You can obtain a copy of LGPL 3.0 license at:


QtNetworkNg require QtCore, QtNetwork to build. SSL and crypto is supported using embedded LibreSSL.

Qt 5 -

Supported Platforms

Linux, Android and OpenBSD is supported.

Macos, iOS is not tested yet, as I have no mac machines.

Windows is supported partially. Because the Qt eventloop is not very efficient, a separate libev event loop is provided in Linux which is not available in Windows. GZip compression is not supported under Windows if zlib library not present.

QtNetworkNg uses more effective boost::context asm code in arm, arm64, x86, amd64 machines, and uses native ucontext or windows fiber API in other architectures.

Towards 1.0

  • [ ] Complete reference documents
  • [x] Implements an HTTP 1.0 server.
  • [x] HTTP support gzip compression.
  • [x] HttpResponse support stream.
  • [x] Support HTTP proxy and cache.
  • [ ] Built as shared library(DLL)
  • [x] A simple replacement for libev in Windows.
  • [ ] Add more OpenSSL functions.
  • [ ] Support verification/ALPS for https connection.
  • [ ] Support MacOS and iOS platforms.
  • [ ] Remove QtNetwork dependence.

Towards 2.0

  • [ ] Support HTTP/2
  • [ ] Support HTTP/3
  • [ ] Support Kademlia


  1. Clone QtNetworkNg from github as git subrepository.
  2. include qtnetworkng/qtnetworkng.pri in your file.
  3. include qtnetworkng.h in you cpp files.

How to Contribute

Create a pull request on with your patch, then make a pull request to me.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c-plus-plus (18,997
c (15,734
http (939
network (485
qt (371
crypto (251
tcp (249
http-server (200
http-client (189
socks5 (83
http-proxy (79
openssl (73
coroutine (70
asio (30
socks5-proxy (29
kcp (22