NTDLS.DatagramMessaging
1.8.1
dotnet add package NTDLS.DatagramMessaging --version 1.8.1
NuGet\Install-Package NTDLS.DatagramMessaging -Version 1.8.1
<PackageReference Include="NTDLS.DatagramMessaging" Version="1.8.1" />
<PackageVersion Include="NTDLS.DatagramMessaging" Version="1.8.1" />
<PackageReference Include="NTDLS.DatagramMessaging" />
paket add NTDLS.DatagramMessaging --version 1.8.1
#r "nuget: NTDLS.DatagramMessaging, 1.8.1"
#:package NTDLS.DatagramMessaging@1.8.1
#addin nuget:?package=NTDLS.DatagramMessaging&version=1.8.1
#tool nuget:?package=NTDLS.DatagramMessaging&version=1.8.1
NTDLS.DatagramMessaging
📦 Be sure to check out the NuGet package: https://www.nuget.org/packages/NTDLS.DatagramMessaging
NTDLS.DatagramMessaging is a set of classes and extensions methods that allow you to send/receive UDP packets with ease. It handles corruption checks, concatenation, fragmentation, serialization and compression with optional overloads.
UDP Sever (Event based):
Here we are instantiating a DmMessenger and giving it a listen port. This will cause the manager to go into listen mode. Any received messages will handled by the OnDatagramReceived event.
static void Main()
{
var udpManager = new DmClient();
udpManager.OnDatagramReceived += UdpManager_OnDatagramReceived;
udpManager.Listen(1234);
udpManager.Stop();
}
private static void UdpManager_OnDatagramReceived(DmContext context, IDmDatagram datagram)
{
if (datagram is MyFirstUDPPacket myFirstUDPPacket)
{
context.Dispatch(myFirstUDPPacket); //Echo the datagram back to the sender.
Console.WriteLine($"{myFirstUDPPacket.Message}->{myFirstUDPPacket.UID}->{myFirstUDPPacket.TimeStamp}");
}
}
UDP Sever (Convention based):
Here we are instantiating a DmMessenger and giving it a listen port. This will cause the manager to go into listen mode. Any received messages will handled by the class HandlePackets which was suppled to the UDP messenger by a call to AddHandler().
static void Main()
{
var udpManager = new DmClient();
udpManager.AddHandler(new HandlePackets());
udpManager.Listen(1234);
Console.ReadLine();
udpManager.Stop();
}
private class HandlePackets : IDmMessageHandler
{
private class HandlePackets : IDmMessageHandler
{
public static void DatagramHandler(DmContext context, MyFirstUDPPacket datagram)
{
context.Dispatch(datagram); //Echo the datagram back to the sender.
Console.WriteLine($"{datagram.Message}->{datagram.UID}->{datagram.TimeStamp}");
}
}
}
UDP Client:
Here we are instantiating a DmMessenger without a listen port. This means that this this manager is in write-only mode. Note that we could also receive data by calling Listen(). We are going to loop and send frames containing serialized MyFirstUDPPacket.
static void Main()
{
var udpManager = new DmClient();
udpManager.Connect("127.0.0.1", 1234);
udpManager.OnDatagramReceived += UdpManager_OnDatagramReceived;
int packetNumber = 0;
while (true)
{
udpManager.Dispatch(new MyFirstUDPPacket($"Packet#:{packetNumber++} "));
Thread.Sleep(10);
}
Console.ReadLine();
udpManager.Stop();
}
Supporting Code:
The class that we are going to be serializing and deserializing in the examples.
public class MyFirstUDPPacket: IDmDatagram
{
public DateTime TimeStamp { get; set; } = DateTime.UtcNow;
public Guid UID { get; set; } = Guid.NewGuid();
public string Message { get; set; } = string.Empty;
public MyFirstUDPPacket()
{
}
public MyFirstUDPPacket(string message)
{
Message = message;
}
}
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Caching.Memory (>= 10.0.2)
- NTDLS.Semaphore (>= 3.5.4)
- protobuf-net (>= 3.2.56)
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Caching.Memory (>= 10.0.2)
- NTDLS.Semaphore (>= 3.5.4)
- protobuf-net (>= 3.2.56)
-
net9.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Caching.Memory (>= 10.0.2)
- NTDLS.Semaphore (>= 3.5.4)
- protobuf-net (>= 3.2.56)
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.8.1 | 5 | 2/5/2026 |
| 1.8.0 | 6 | 2/5/2026 |
| 1.7.6 | 291 | 11/14/2025 |
| 1.7.5 | 202 | 10/27/2025 |
| 1.7.4 | 251 | 5/5/2025 |
| 1.7.3 | 214 | 5/5/2025 |
| 1.7.2 | 156 | 5/2/2025 |
| 1.7.1 | 238 | 3/11/2025 |
| 1.7.0 | 239 | 3/11/2025 |
| 1.6.2 | 267 | 3/10/2025 |
| 1.6.1 | 239 | 3/10/2025 |
| 1.6.0 | 253 | 3/10/2025 |
| 1.5.2 | 234 | 3/10/2025 |
| 1.5.1 | 232 | 3/10/2025 |
| 1.5.0 | 230 | 3/10/2025 |
| 1.4.0 | 283 | 3/8/2025 |
| 1.3.7 | 162 | 3/2/2025 |
| 1.3.6 | 149 | 1/8/2025 |
| 1.3.5 | 189 | 1/4/2025 |
| 1.3.4 | 189 | 1/4/2025 |
| 1.3.3 | 190 | 12/31/2024 |
| 1.3.2 | 171 | 12/3/2024 |
| 1.3.1 | 370 | 2/19/2024 |
| 1.3.0 | 321 | 2/15/2024 |
| 1.2.0 | 329 | 2/15/2024 |
Major changes to server/client architecture to support better scalability and maintainability.