NTDLS.UDPPacketFraming
1.0.1
dotnet add package NTDLS.UDPPacketFraming --version 1.0.1
NuGet\Install-Package NTDLS.UDPPacketFraming -Version 1.0.1
<PackageReference Include="NTDLS.UDPPacketFraming" Version="1.0.1" />
paket add NTDLS.UDPPacketFraming --version 1.0.1
#r "nuget: NTDLS.UDPPacketFraming, 1.0.1"
// Install NTDLS.UDPPacketFraming as a Cake Addin
#addin nuget:?package=NTDLS.UDPPacketFraming&version=1.0.1
// Install NTDLS.UDPPacketFraming as a Cake Tool
#tool nuget:?package=NTDLS.UDPPacketFraming&version=1.0.1
NTDLS.UDPPacketFraming
📦 Be sure to check out the NuGet pacakge: https://www.nuget.org/packages/NTDLS.UDPPacketFraming
NTDLS.UDPPacketFraming is a set of classes and extensions methods that allow you to send/receive UPD packets with ease. It handles corruption checks, concatenation, fragmentation, serialization and adds compression.
UPD Sever:
Here we are instantiating a UdpMessageManager and giving it a listen port. This will cause the manager to go into listen mode and pass any received frames to the supplied callback.
static void Main()
{
var udpManager = new UdpMessageManager(1234, ProcessFrameNotificationCallback);
}
private static void ProcessFrameNotificationCallback(IUDPPayloadNotification payload)
{
if (payload is MyFirstUPDPacket myFirstUPDPacket)
{
Console.WriteLine($"{myFirstUPDPacket.Message}->{myFirstUPDPacket.UID}->{myFirstUPDPacket.TimeStamp}");
}
}
UPD Client:
Here we are instantiating a UdpMessageManager without a a listen port. This means that this this manager is in write-only mode. We are going to loop and send frames containing serialized MyFirstUDPPacket.
static void Main()
{
var udpManager = new UdpMessageManager();
int packetNumber = 0;
while (true)
{
udpManager.WriteMessage("127.0.0.1", 1234,
new MyFirstUPDPacket($"Packet#:{packetNumber++} "));
Thread.Sleep(100);
}
}
Supporting Code:
The class that we are going to be serializing and deserializing in the examples.
public class MyFirstUPDPacket: IUDPPayloadNotification
{
public DateTime TimeStamp { get; set; } = DateTime.UtcNow;
public Guid UID { get; set; } = Guid.NewGuid();
public string Message { get; set; } = string.Empty;
public MyFirstUPDPacket()
{
}
public MyFirstUPDPacket(string message)
{
Message = message;
}
}
Product | Versions 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. |
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
- NTDLS.Semaphore (>= 3.1.0)
- protobuf-net (>= 3.2.30)
-
net7.0
- Newtonsoft.Json (>= 13.0.3)
- NTDLS.Semaphore (>= 3.1.0)
- protobuf-net (>= 3.2.30)
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
- NTDLS.Semaphore (>= 3.1.0)
- protobuf-net (>= 3.2.30)
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 |
---|
Resolved unhandled exception in UDP receive.