Help Us Build
Better Async
Networking

Corosio is a coroutine-native C++20 networking library — the next evolution of Asio. Before we submit it to Boost for formal review, we'd love your eyes on it. Try the echo server below and tell us what's broken or confusing.

Get Started → Why Corosio?
Quick Test

Build an Echo Server in 10 Minutes.

Two files, four commands, no dependency wrangling. Follow along, then scroll down and let us know how it went.

1
Create Two Files

Make a new folder anywhere. Inside it, create CMakeLists.txt and main.cpp with the contents below.

CMakeLists.txt
cmake_minimum_required(VERSION 3.14...4.2)
project(echo_server VERSION 1.0 LANGUAGES CXX)

include(FetchContent)

FetchContent_Declare(corosio
  GIT_REPOSITORY https://github.com/cppalliance/corosio.git
  GIT_TAG        develop
  GIT_SHALLOW    TRUE)

FetchContent_MakeAvailable(corosio)

add_executable(echo_server main.cpp)
target_link_libraries(echo_server Boost::corosio)
main.cpp — Echo Server
#include <boost/capy.hpp>
#include <boost/corosio.hpp>
#include <iostream>

namespace corosio = boost::corosio;
namespace capy    = boost::capy;

capy::task<> echo_session(corosio::tcp_socket sock)
{
    char buf[1024];
    for (;;)
    {
        auto [ec, n] = co_await sock.read_some(
            capy::mutable_buffer(buf, sizeof(buf)));
        auto [wec, wn] = co_await capy::write(sock,
            capy::const_buffer(buf, n));
        if (ec || wec) break;
    }
    sock.close();
}

capy::task<> accept_loop(
    corosio::tcp_acceptor& acc,
    corosio::io_context& ioc)
{
    auto ep = acc.local_endpoint();
    std::cout << "Listening on port " << ep.port() << "\n";
    for (;;)
    {
        corosio::tcp_socket peer(ioc);
        auto [ec] = co_await acc.accept(peer);
        if (ec) { std::cout << ec.message(); continue; }
        capy::run_async(ioc.get_executor())(
            echo_session(std::move(peer)));
    }
}

int main(int argc, char* argv[])
{
    unsigned short port = 8080;
    if (argc > 1)
        port = static_cast<unsigned short>(std::atoi(argv[1]));
    corosio::io_context ioc;
    corosio::tcp_acceptor acc(ioc, corosio::endpoint(port));
    capy::run_async(ioc.get_executor())(accept_loop(acc, ioc));
    ioc.run();
}
⚠  The CMakeLists.txt may change — check github.com/sgerbino/corosio-quickstart for the latest.
2
Configure

Run this from your project folder. CMake will fetch Corosio and all its dependencies automatically — nothing to install by hand.

$ cmake -S . -B build
3
Build & Run

Compile, then start the server. You should see it listening on port 8080.

$ cmake --build build
$ ./build/echo_server
Listening on port 8080
4
Test It

Open a second terminal and send it something. You should see your message echoed back.

$ echo "Hello World" | nc localhost 8080
Hello World
Quick Test Repo → Full Documentation
Your Experience

How Did It Go?

Whether you got it running or hit a wall on step one, we want to hear about it. Doesn't need to be polished — rough notes are great. Anything you tell us here goes directly to the people building this.