ProtobufOverUdp.Listener 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ProtobufOverUdp.Listener --version 1.1.0
                    
NuGet\Install-Package ProtobufOverUdp.Listener -Version 1.1.0
                    
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.Listener" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProtobufOverUdp.Listener" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ProtobufOverUdp.Listener" />
                    
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.Listener --version 1.1.0
                    
#r "nuget: ProtobufOverUdp.Listener, 1.1.0"
                    
#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.Listener@1.1.0
                    
#: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.Listener&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ProtobufOverUdp.Listener&version=1.1.0
                    
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 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

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.1.5 294 12/6/2025
1.1.4 223 11/25/2025
1.1.2 194 11/25/2025
1.1.1 191 11/25/2025
1.1.0 194 11/24/2025
1.0.3 193 11/23/2025
1.0.2 191 11/23/2025
1.0.1 192 11/23/2025
1.0.0 200 11/23/2025