# Quickstart

> A server answers on one or more interfaces, and a client calls it; neither starts a thread.

1.0.0-rc.1 · b7577426

A server answers on one or more interfaces, and a client calls it; neither starts a thread.

```cpp
#include <thread>

#include <ucall/ucall.hpp>

namespace uc = unum::ucall;

void greet(uc::request_t request) noexcept {
    auto [name, name_status] = request.path_parameter("name");
    if (name_status.failed()) return;
    ucall_reply_part_t const parts[] {uc::bytes_part("Hello, "), uc::bytes_part(name)};
    ucall_bytes_view_t const headers[] {uc::bytes_view("content-type: text/plain")};
    uc::deferred<> sent; // final on return, as the parts are bytes alone
    [[maybe_unused]] uc::status_t const replied =
        std::move(request).reply_parts(ucall_http_status_ok_k, headers, parts, sent);
}

int main() {
    uc::interface_t const interfaces[] {{.address = "127.0.0.1:0"}};
    auto [server, server_status] = uc::server_t::make(interfaces);
    if (server_status.failed()) return 1;
    uc::status_t const routed = server.get<greet>("/hello/{name}");
    if (routed.failed()) return 1;
    auto [address, address_status] = server.address(0);

    auto [client, client_status] = uc::client_t::make({.max_concurrent_connections = 1});
    std::thread polling([&server] { [[maybe_unused]] uc::status_t const polled = server.take_calls(0); });
    char url[128];
    std::snprintf(url, sizeof url, "http://%.*s/hello/world", int(address.size()), address.data());
    auto [response, response_status] = client.get(url);
    server.stop();
    polling.join();
    auto [body, body_status] = response.body();
    return response_status.failed() || body_status.failed() || body != "Hello, world";
}
```

The polling thread runs the handler, the client blocks in `get` until its response arrives, and `stop` releases the polling thread so it can be joined. Every fallible verb answers a `status_t` or an `expected<T>`, unpacked as `auto [value, status]`.
