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.

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::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.

Next Steps

With an endpoint created, you can now start discovering and connecting to other endpoints. Explore the following guides to learn more: