Netorrent 0.0.2

dotnet add package Netorrent --version 0.0.2
                    
NuGet\Install-Package Netorrent -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Netorrent" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Netorrent" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Netorrent" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Netorrent --version 0.0.2
                    
#r "nuget: Netorrent, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Netorrent@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Netorrent&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Netorrent&version=0.0.2
                    
Install as a Cake Tool

Netorrent

A async-first .NET 10.0 BitTorrent client library for downloading and seeding torrents.

Installation

Stable Release

dotnet add package Netorrent

Nightly Builds (for testing latest features)

dotnet add package Netorrent --version 1.0.0-nightly-*

Requirements:

  • .NET 10.0 or higher
  • Dependencies automatically included:
    • Microsoft.Extensions.Logging.Abstractions
    • R3 (Reactive Extensions)
    • ZLinq (High-performance LINQ)

Quick Start

using Netorrent.TorrentFile;

await using var client = new TorrentClient();
await using var torrent = await client.LoadTorrentAsync(
    "path/to/file.torrent", 
    "output/directory"
);

await torrent.CheckAsync();  // Verify existing data
await torrent.StartAsync();  // Start downloading

await torrent.Completion;    // Wait for completion

Usage Examples

Statistics Monitoring

using Netorrent.TorrentFile;

await using var client = new TorrentClient();
await using var torrent = await client.LoadTorrentAsync("file.torrent", "output");

await torrent.StartAsync();
var completionTask = torrent.Completion.AsTask();

// Monitor detailed statistics
while (!completionTask.IsCompleted)
{
    var data = torrent.Statistics.Data;
    var peers = torrent.Statistics.Peers;
    var check = torrent.Statistics.Check;
    
    Console.WriteLine($"Progress: {(double)data.Verified.Bytes / data.Total.Bytes:P1}");
    Console.WriteLine($"Download speed: {data.DownloadSpeed.BytesPerSecond} B/s");
    Console.WriteLine($"Upload speed: {data.UploadSpeed.BytesPerSecond} B/s");
    Console.WriteLine($"Connected peers: {peers.ConnectedCount}");
    Console.WriteLine($"Pieces checked: {check.CheckedPiecesCount} / {check.TotalPiecesCount}");
    
    await Task.Delay(1000);
}

await completionTask;

Advanced Configuration

using Microsoft.Extensions.Logging;
using Netorrent.TorrentFile;

var logger = LoggerFactory.Create(builder => builder.AddConsole()).CreateLogger<Netorrent.TorrentFile.TorrentClient>();

await using var client = new TorrentClient(options => options with
{
    Logger = logger,
    UsedAdressProtocol = UsedAddressProtocol.Ipv4,
    UsedTrackers = UsedTrackers.Http | UsedTrackers.Udp
});

await using var torrent = await client.LoadTorrentAsync("file.torrent", "output");

await torrent.CheckAsync();
await torrent.StartAsync();
await torrent.Completion;

Torrent Creation

using Netorrent.TorrentFile;

await using var client = new TorrentClient();

// Create torrent from single file
var torrent = await client.CreateTorrentAsync(
    "path/to/file.txt",
    "http://tracker.example.com/announce"
);

// Create torrent from directory with multiple trackers
var torrent = await client.CreateTorrentAsync(
    "path/to/directory",
    "http://primary.tracker.com/announce",
    announceUrls: ["http://backup1.tracker.com/announce", "http://backup2.tracker.com/announce"],
    pieceLength: 512 * 1024  // 512KB pieces
);

Stopping and Canceling Torrents

using Netorrent.TorrentFile;

await using var client = new TorrentClient();
await using var torrent = await client.LoadTorrentAsync("file.torrent", "output");

await torrent.StartAsync();

// Request a stop (doesn't wait for ongoing operations to finish)
torrent.Stop();
Console.WriteLine("Stop requested");

// Or stop gracefully (waits for current operations to complete)
await torrent.StopAsync();
Console.WriteLine("Torrent stopped gracefully");

Performance Considerations

The library is designed with async-first architecture for optimal performance:

  • Channel-based communication between components
  • Memory pooling for efficient buffer management
  • Concurrent collections for thread-safe operations

Package Versions

📦 Stable Releases

  • Purpose: Production-ready versions with stable APIs
  • Versioning: Semantic Versioning (e.g., 1.0.0, 1.1.0, 1.0.1)
  • Updates: Bug fixes and new features
  • Installation: dotnet add package Netorrent

🌙 Nightly Builds

  • Purpose: Latest code from every commit to develop branch
  • Versioning: Timestamped with commit hash (e.g., 1.0.0-nightly-20250114-1430-a1b2c3d)
  • Updates: Per-commit builds for immediate testing
  • Installation: dotnet add package Netorrent --version 1.0.0-nightly-*
  • Warning: May contain breaking changes or bugs

Features

  • Torrent files - Complete .torrent file support
  • HTTP Trackers - Full HTTP tracker protocol implementation
  • Peer Wire Protocol - TCP peer communication
  • UDP Trackers - High-performance UDP tracker support
  • Piece Verification - SHA-1 hash verification of downloaded pieces
  • Multi-tracker Support - Primary and backup tracker support
  • Resume Downloads - Support for partially downloaded torrents
  • Real-time Statistics - Comprehensive download/upload monitoring
  • Async/Await Support - Modern async-first API design
  • Cancellation Support - Full CancellationToken integration
  • Torrent Creation - Create torrents from files and directories

BEP Implementation

Netorrent implements the following BitTorrent Enhancement Proposals (BEPs):

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 29 1/21/2026
0.0.2-nightly-2026-01-22T22... 16 1/22/2026
0.0.2-nightly-2026-01-22T21... 31 1/22/2026
0.0.2-nightly-2026-01-22T21... 24 1/22/2026
0.0.2-nightly-2026-01-22T20... 22 1/22/2026
0.0.2-nightly-2026-01-22T09... 25 1/22/2026
0.0.2-nightly-2026-01-21T20... 26 1/21/2026
0.0.2-nightly-2026-01-21T20... 29 1/21/2026
0.0.1 28 1/21/2026
0.0.1-nightly-2026-01-21T20... 21 1/21/2026
0.0.1-nightly-2026-01-21T20... 22 1/21/2026
0.0.1-nightly-2026-01-21T20... 24 1/21/2026
0.0.1-nightly-2026-01-21T20... 19 1/21/2026
0.0.1-nightly-2026-01-21T20... 25 1/21/2026
0.0.1-nightly-2026-01-21T19... 24 1/21/2026
0.0.1-nightly-2026-01-20T20... 31 1/20/2026
0.0.1-nightly-2026-01-20T12... 27 1/20/2026
0.0.1-nightly-2026-01-19T18... 26 1/19/2026
0.0.1-nightly-2026-01-19T16... 31 1/19/2026
0.0.1-nightly-2026-01-18T20... 29 1/18/2026
0.0.1-nightly-2026-01-18T00... 28 1/18/2026
0.0.1-nightly-2026-01-16T13... 31 1/16/2026
0.0.1-nightly-2026-01-16T12... 25 1/16/2026
0.0.1-nightly-2026-01-16T12... 23 1/16/2026
0.0.1-nightly-2026-01-16T11... 32 1/16/2026
0.0.1-nightly-2026-01-15T18... 31 1/15/2026
0.0.1-nightly-2026-01-15T16... 29 1/15/2026
0.0.1-nightly-2026-01-15T16... 29 1/15/2026
0.0.1-nightly-2026-01-14T22... 38 1/14/2026
0.0.1-nightly-2026-01-14T22... 28 1/14/2026
0.0.1-nightly-2026-01-14T22... 32 1/14/2026
0.0.1-nightly-2026-01-14T22... 27 1/14/2026
0.0.1-nightly-2026-01-14T22... 32 1/14/2026
0.0.1-nightly-2026-01-14T22... 28 1/14/2026
0.0.1-nightly-2026-01-14T22... 35 1/14/2026
0.0.1-nightly-2026-01-14T22... 30 1/14/2026
0.0.1-nightly-2026-01-14T22... 28 1/14/2026
0.0.1-nightly-2026-01-14T22... 28 1/14/2026
0.0.1-nightly-2026-01-14T22... 28 1/14/2026
0.0.1-nightly-2026-01-14T22... 32 1/14/2026
0.0.1-nightly-2026-01-14T22... 28 1/14/2026
0.0.1-nightly-2026-01-14T22... 25 1/14/2026
0.0.1-nightly-2026-01-14T22... 29 1/14/2026
0.0.1-nightly-2026-01-14T22... 29 1/14/2026
0.0.1-nightly-2026-01-14T21... 29 1/14/2026
0.0.1-nightly-2026-01-14T21... 24 1/14/2026
0.0.1-nightly-2026-01-14T21... 28 1/14/2026
0.0.1-nightly-2026-01-14T21... 26 1/14/2026
0.0.1-nightly-2026-01-14T21... 29 1/14/2026
0.0.1-nightly-2026-01-14T21... 33 1/14/2026