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.

ALPNs

All iroh protocols build on QUIC connections, and use application level protocol negotiation (ALPNs) to run multiple protocols on the same QUIC endpoint. ALPNs are part of the QUIC spec, which we take advantage of to build iroh protocols. Each protocol registerted The ALPN is a string that identifies the protocol. For example, the iroh-blobs protocol ALPN is /iroh-bytes/4.

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.