ProtobufOverUdp.Common 1.0.6

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

ProtobufOverUdp

A small .NET helper library that makes it easy to send and receive Protocol Buffers messages over UDP.

It wraps UdpClient and Google.Protobuf behind a simple API, so you can focus on your message contracts instead of byte arrays, ports and parsing.


📦 Installation

Common package includes UdpService which is necessary to Send protobuf messages over UDP.
NuGet link: ProtobufOverUdp.Common

dotnet add package ProtobufOverUdp.Common

Listener package includes UdpListener and interface IUdpMessageHandler which is necessary to Receive protobuf messages over UDP and handle them properly.
NuGet link: ProtobufOverUdp.Listener

dotnet add package ProtobufOverUdp.Listener

🔧 Usage

📤 Send protobuf over UDP

To send protobuf messages over UDP, download ProtobufOverUdp.Common NuGet package, then add necessary services in your Program.cs

builder.Services.AddUdpService(builder.Configuration);

Now, you can inject IUdpService and send protobuf messages via UDP this way:

await udpService.SendMessageAsync(message, request.IpAddress, request.Port);

If you have the same target IP address and port everywhere, you can specify them this way:

builder.Services.AddUdpService(builder.Configuration, opt =>
{
    opt.DestinationIpAddress = "127.0.0.1";
    opt.DestinationPort = 5123;
});

Now, you can simply use the method this way:

await udpService.SendMessageAsync(message);

📥 Receive protobuf over UDP

To receive protobuf messages over UDP, download ProtobufOverUdp.Listener NuGet package, then add necessary services in your Program.cs

builder.Services.AddUdpService(context.Configuration);
builder.Services.AddUdpListener();

Now, for each protobuf type you should have its own UdpMessageHandler. Implement them in a similar way (Notification here is your message):

public sealed class NotificationUdpMessageHandler(ILogger<StatusUdpMessageHandler> logger) : IUdpMessageHandler<Notification>
{
    public Task HandleAsync(Notification message, CancellationToken token)
    {
        if (logger.IsEnabled(LogLevel.Information))
        {
            logger.LogInformation("Received notification {Id} {Text}; Current Time: {CurrentTime}.", message.Id,
                message.Text, DateTimeOffset.UtcNow);
        }
        
        return Task.CompletedTask;
    }
}

Finally, register them in DI:

builder.Services.AddUdpMessageHandler<Notification, NotificationUdpMessageHandler>();

Now, your application will listen to coming UDP messages and handle them properly.

▶️ Demo

There are ListenerDemo and PublisherDemo projects. You can run them to see how this application works.

dotnet run --project .\src\ListenerDemo\ListenerDemo.csproj --launch-profile "ListenerDemo"
dotnet run --project .\src\PublisherDemo\PublisherDemo.csproj --launch-profile "http"

Now, you can use Postman collection (download it from PostmanCollections folder or from this link)

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 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 (1)

Showing the top 1 NuGet packages that depend on ProtobufOverUdp.Common:

Package Downloads
ProtobufOverUdp.Listener

ProtobufOverUdp.Listener is a useful library for receiving and parsing protobufs.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 318 11/25/2025
1.0.5 209 11/25/2025
1.0.3 213 11/25/2025
1.0.2 232 11/23/2025
1.0.1 227 11/23/2025
1.0.0 214 11/23/2025