ThreeByte.LinkLib.UdpLink 1.0.3

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

Asynchronous UDP client with message queuing, configurable endpoints, and thread-safe operation.

NuGet .NET


✨ Features

Feature Description
📡 Connectionless Low-latency UDP datagrams — no handshake overhead
📦 Message Queuing Incoming datagrams queued FIFO (up to 100 messages)
🔒 Thread-Safe All operations protected with locking
Fully Async Non-blocking BeginSend / BeginReceive patterns
🎛️ Dual Port Config Separate remote and local port configuration
🔔 Event-Driven Events for data arrival, errors, and enable/disable state

📦 Installation

dotnet add package ThreeByte.LinkLib.UdpLink

or via the NuGet Package Manager:

Install-Package ThreeByte.LinkLib.UdpLink

🚀 Quick Start

using ThreeByte.LinkLib.UdpLink;

// Send to a remote device on port 9000, listen on local port 9001
var udp = new AsyncUdpLink("192.168.1.50", remotePort: 9000, localPort: 9001);

// Subscribe to incoming data
udp.DataReceived += (s, e) =>
{
    byte[]? data = udp.GetMessage();
    if (data != null)
        Console.WriteLine($"Received {data.Length} bytes");
};

udp.ErrorOccurred += (s, ex) =>
    Console.WriteLine($"Error: {ex.Message}");

// Send a datagram
byte[] payload = System.Text.Encoding.ASCII.GetBytes("PING");
udp.SendMessage(payload);

// Check for queued data
while (udp.HasData)
{
    byte[]? response = udp.GetMessage();
}

// Clean up
udp.Dispose();

Dynamic Local Port

// Let the OS assign a local port (default behavior)
var udp = new AsyncUdpLink("10.0.0.1", remotePort: 8080);

📖 API Reference

Constructors
AsyncUdpLink(string address, int remotePort, int localPort = 0, bool enabled = true)
AsyncUdpLink(UdpLinkSettings settings, bool enabled = true)
Properties
Property Type Description
IsEnabled bool Whether the link is actively receiving
Address string Remote host address
Port int Remote port number
HasData bool Whether there are queued incoming datagrams
Methods
Method Returns Description
SendMessage(byte[]) void Sends a byte array datagram to the remote endpoint
GetMessage() byte[]? Dequeues the next incoming datagram (FIFO)
SetEnabled(bool) void Starts or stops the receive loop
Dispose() void Releases the UDP socket and all resources
Events
Event Args Description
IsEnabledChanged bool Fires when enabled state changes
ErrorOccurred Exception Fires on communication errors
DataReceived EventArgs Fires when a datagram arrives

🔧 Configuration

Use UdpLinkSettings for structured configuration:

// With explicit local port
var settings = new UdpLinkSettings("10.0.0.1", remotePort: 8080, localPort: 8081);

// With dynamic local port (default 0)
var settings = new UdpLinkSettings("10.0.0.1", remotePort: 8080);
Property Type Description
Address string Remote host address
RemotePort int Remote port to send to
LocalPort int Local port to bind (0 = OS-assigned)

🏗️ Architecture

┌────────────────────────────────────────────┐
│              AsyncUdpLink                  │
│                                            │
│  ┌──────────────┐    ┌──────────────────┐  │
│  │  Send (Async) │    │ Receive (Async)  │  │
│  │ → Remote:Port │    │ ← Local:Port     │  │
│  └──────┬───────┘    └────────┬─────────┘  │
│         │                     │            │
│         ▼                     ▼            │
│  ┌──────────────────────────────────────┐  │
│  │     Thread-Safe Message Queue        │  │
│  │          (FIFO, max 100)             │  │
│  └──────────────────────────────────────┘  │
│         │                                  │
│         ▼                                  │
│  ┌──────────────────────────────────────┐  │
│  │   Event Dispatch (Data / Error)      │  │
│  └──────────────────────────────────────┘  │
└────────────────────────────────────────────┘

💡 TCP vs UDP — When to Use This Package

Scenario Use
Reliable, ordered data transfer ThreeByte.LinkLib.TcpLink
Low-latency, fire-and-forget messaging ThreeByte.LinkLib.UdpLink
Broadcast / multicast discovery ThreeByte.LinkLib.UdpLink
Streaming sensor data ThreeByte.LinkLib.UdpLink
Command-response protocols ThreeByte.LinkLib.TcpLink

🎯 Platform Support

Platform Supported
.NET 10.0
.NET Standard 2.1
.NET Standard 2.0
Windows
Linux
macOS

📄 License

Part of the ThreeByte.LinkLib family of communication libraries.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.3 31 3/27/2026
1.0.2 70 3/25/2026
1.0.1 361 12/24/2025
1.0.0 1,351 2/15/2025