UsenetSharp 1.0.6

dotnet add package UsenetSharp --version 1.0.6
                    
NuGet\Install-Package UsenetSharp -Version 1.0.6
                    
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="UsenetSharp" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UsenetSharp" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="UsenetSharp" />
                    
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 UsenetSharp --version 1.0.6
                    
#r "nuget: UsenetSharp, 1.0.6"
                    
#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 UsenetSharp@1.0.6
                    
#: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=UsenetSharp&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=UsenetSharp&version=1.0.6
                    
Install as a Cake Tool

UsenetSharp

A high-performance .NET library for Usenet NNTP protocol with yEnc support.

Features

  • Asynchronous NNTP client implementation
  • SSL/TLS support for secure connections
  • Authentication support
  • Article retrieval (ARTICLE, BODY, STAT commands)
  • yEnc decoding via RapidYencSharp integration
  • Thread-safe operations
  • High-performance streaming

Installation

Install via NuGet:

dotnet add package UsenetSharp

Usage

Basic Connection and Authentication

using UsenetSharp.Clients;

var client = new UsenetClient();

// Connect to Usenet server
await client.ConnectAsync("news.example.com", 563, useSsl: true, cancellationToken);

// Authenticate
await client.AuthenticateAsync("username", "password", cancellationToken);

Retrieving Articles

// Get article body
var bodyResponse = await client.BodyAsync("article-id@example.com", cancellationToken);
using (var stream = bodyResponse.Stream)
{
    // Process article body stream
}

// Get full article (headers + body)
var articleResponse = await client.ArticleAsync("article-id@example.com", cancellationToken);
Console.WriteLine($"Headers: {articleResponse.Headers}");
using (var stream = articleResponse.Stream)
{
    // Process article stream
}

Checking Article Existence with STAT

// Check if an article exists (typically used for validation or inventory purposes)
// Note: In most cases, you would directly call BodyAsync or ArticleAsync
// rather than checking with STAT first
var statResponse = await client.StatAsync("article-id@example.com", cancellationToken);

if (statResponse.Exists)
{
    Console.WriteLine($"Article exists with response code: {statResponse.ResponseCode}");
}
else
{
    Console.WriteLine($"Article not found. Response code: {statResponse.ResponseCode}");
}

Decoding yEnc Content with YencStream

using UsenetSharp.Streams;

// Get article body that contains yEnc-encoded data
using var bodyResponse = await client.BodyAsync("yenc-article-id@example.com", cancellationToken);

// Wrap the body stream with YencStream for automatic decoding
using var yencStream = new YencStream(bodyResponse.Stream);

// Get yEnc headers (filename, size, part info, etc.)
var yencHeaders = await yencStream.GetYencHeadersAsync(cancellationToken);
if (yencHeaders != null)
{
    Console.WriteLine($"File: {yencHeaders.FileName}");
    Console.WriteLine($"Size: {yencHeaders.FileSize} bytes");
    Console.WriteLine($"Part: {yencHeaders.PartNumber}/{yencHeaders.TotalParts}");
}

// Process the decoded stream
// The yencStream can be read from directly and will provide decoded binary data

Server Date/Time

var dateResponse = await client.DateAsync(cancellationToken);
Console.WriteLine($"Server time: {dateResponse.DateTime}");

Requirements

  • .NET 9.0 or later
  • RapidYencSharp package (automatically installed as dependency)

Running Tests

Before running the unit tests, you need to update the credentials in UsenetSharpTest/Credentials.cs with your Usenet server details:

public static class Credentials
{
    public const string Host = "news.example.com";
    public const string Username = "your-username";
    public const string Password = "your-password";
}

Once configured, run the tests using:

dotnet test

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Repository

https://github.com/nzbdav-dev/UsenetSharp

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.0.6 546 12/23/2025
1.0.5 245 12/15/2025
1.0.4 1,056 12/4/2025
1.0.3 217 12/4/2025
1.0.2 696 12/3/2025
1.0.1 111 11/29/2025
1.0.0 349 11/21/2025