Skip to main content
An endpoint is the core building block of an iroh node. It manages network connections, handles incoming and outgoing traffic, and provides the necessary infrastructure for implementing protocols. Once you have an Endpoint, you can use it to create connections or accept incoming connections from other endpoints. Unlike HTTP servers, which listen on specific ports, iroh Endpoints use a peer-to-peer model to establish connections. This means that endpoints can connect directly to each other without relying on a central server. This means that endpoints can be more resilient to network issues and can operate in a wider range of network environments.

Creating an Endpoint

This method initializes a new endpoint and binds it to a local address, allowing it to listen for incoming connections.
use iroh::Endpoint;

#[tokio::main]
async fn main() {
    let endpoint = Endpoint::builder().bind().await?;
    // ...
}
  1. bind creates the endpoint and starts listening for incoming connections
  2. await keyword is used to wait for the endpoint to be created in an asynchronous context.