← Back to DevLog

May 18, 2026 · By Kaleb de Souza, Core Architect · 7 min read

Building an Async HTTP Server in Pure Dryad

One of Dryad's boldest claims is that its entire standard library — including HTTP servers, JSON parsers, and TLS — can be written in pure Dryad code, without writing a single line of C++.

To prove this, we built a fully functional HTTP/1.1 server in approximately 200 lines of Dryad. It uses the async/await syntax, the EventLoop class (built on epoll/kqueue syscalls), and the Socket class from the standard library.

Here's how the request lifecycle works:

  1. The server creates a TCP socket via #<tcp> native directive and binds to port 8080.

  2. It registers the listening socket with the EventLoop, which uses epoll_wait (Linux) or kevent (macOS) under the hood to multiplex connections.

  3. When a new connection arrives, an async handler is spawned: async function handleClient(socket) { ... }

  4. The handler reads the HTTP request line by line, parses headers entirely in Dryad (string splitting, trimming, dictionary construction), and routes to the appropriate handler.

  5. The response is built as a string and written back to the socket.

All I/O is non-blocking. While one handler awaits a socket read, the event loop picks up other connections. This means a single thread can handle thousands of concurrent connections using epoll's event-driven model.

The result is a self-hosted HTTP stack with no C++ dependency beyond the intrinsic syscalls — exactly what the Minimal Runtime Architecture promises.

Async·HTTP·Networking·Event Loop