Protocols

Iroh is organized into protocols: Composable networking software built on iroh connections.

The foundation of iroh is direct connections, which protocols use to extend up to higher-level functionality. When integrating iroh into an application you can use protocols to quickly add functionality, or write your own protocol(s) to maintain total control over how your application communicates.

ALPN identifiers

Iroh builds on QUIC connections, and uses application level protocol negotiation (ALPN, a widely used and well specified TLS extension) to run multiple protocols on the same QUIC endpoint. An ALPN identifier is the string that identifies the protocol and is used for protocol negotiation between endpoints. For example, the iroh-blobs protocol ALPN is /iroh-bytes/4. This makes sure that an endpoint that accepts a connection can gracefully indicate whether it supports the requested protocol. In the future you'll be able to use multiple ALPN identifiers when connecting as a way to negotiate e.g. protocol versions. For example, you would connect using /iroh-bytes/5 as well as /iroh-bytes/4, and the other side could respond with /iroh-bytes/4 to indicating it doesn't have support for /iroh-bytes/5.

The Accept Loop

The accept loop is the main loop of an iroh server. It listens for incoming connections, and then processes them. The accept loop is the entry point for all iroh protocols, and is where you can add your own protocol to the iroh stack.

Coming from the world of HTTP servers, the accept loop is similar to the main loop of an HTTP server. The main difference is that the accept loop is more flexible, as it can run multiple protocols on the same endpoint. Normally HTTP servers hide the raw accept loop from you, and instead routing to the correct handler based on the URL. In iroh, the accept loop is exposed to you, and you can use it to route to the correct protocol based on the ALPN.