> For the complete documentation index, see [llms.txt](https://xrho.gitbook.io/rho/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xrho.gitbook.io/rho/daemons/api.md).

# API Reference

## Class: `Daemon`

**Header:** `#include <Lines/Daemon.hpp>`

The base daemon. Manages a Gateway with filesystem-based identity.

### Properties

| Property   | Type                            | Description                         |
| ---------- | ------------------------------- | ----------------------------------- |
| `gt`       | `Gateway`                       | The managed Gateway                 |
| `identity` | `DaemonIdentity`                | Loaded identity (keypair + address) |
| `routes`   | `Map<String, NumericalAddress>` | Public key hash → address claims    |

### Methods

```cpp
// Load identity from directory
void loadIdentity(const String& path);

// Load route claims from directory
void loadRoutes(const String& path);

// Access the Gateway
Gateway& gateway() { return gt; }
```

***

## Class: `DaemonHost`

**Header:** `#include <Lines/DaemonHost.hpp>`

A Daemon that also manages outbound connections.

### Properties

| Property   | Type                   | Description         |
| ---------- | ---------------------- | ------------------- |
| `gt`       | `Gateway`              | The managed Gateway |
| `upgrades` | `Array<UpgradeTarget>` | Peers to connect to |

### Methods

```cpp
// Load identity from directory
void loadIdentity(const String& path);

// Load route claims from directory
void loadRoutes(const String& path);

// Load upgrade targets from directory
void loadUpgrades(const String& path);

// Start: hook to bind, connect to all upgrade targets
void start(Bind& bind);

// Tick: update gateway and all client connections
void update();
```

### UpgradeTarget

```cpp
struct UpgradeTarget {
    String label;     // Human-readable name
    String address;   // "host:port" to connect to
    Client* client;   // The Client managing this connection
};
```

### Full Example

```cpp
#include <Lines/DaemonHost.hpp>
#include <Lines/Bind.hpp>

int main(int argc, char** argv) {
    const char* configDir = argv[1];   // "/etc/rho"
    const char* bindAddr  = argv[2];   // "0.0.0.0:9000"

    Bind bind(bindAddr);

    DaemonHost host;
    host.loadIdentity(String(configDir) + "/identity/");
    host.loadRoutes(String(configDir) + "/routes/");
    host.loadUpgrades(String(configDir) + "/upgrades/");
    host.start(bind);

    while (true) {
        bind.update();
        host.update();
        usleep(1000);
    }

    return 0;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xrho.gitbook.io/rho/daemons/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
