Skip to content

Reliable UDP communication with TCP-like delivery guarantees — packet fragmentation, reassembly, and ACK-based retransmission over UDP.

License

Notifications You must be signed in to change notification settings

m9studio/UdpLikeTcp

Repository files navigation

M9Studio.UdpLikeTcp

Reliable UDP communication over unreliable networks with TCP-like delivery guarantees.

NuGet License: Apache-2.0

Features

  • Reliable message delivery over UDP
  • Packet fragmentation and reassembly
  • ACK-based retransmission system
  • Send and receive queues per endpoint
  • NAT traversal ready (via STUN, optional)
  • Simple API using IPEndPoint

Installation

dotnet add package M9Studio.UdpLikeTcp

Usage

Sending data

var socket = new M9Studio.UdpLikeTcp.Socket();
var target = new IPEndPoint(IPAddress.Loopback, 12345);
byte[] message = Encoding.UTF8.GetBytes("Hello over UDP!");
socket.SendTo(target, message);

Receiving data (blocking)

byte[] received = socket.ReceiveFrom(remoteEP);
Console.WriteLine("Received: " + Encoding.UTF8.GetString(received));

Using the event system

socket.DataReceived += (sender) =>
{
    byte[] buffer = socket.ReceiveFrom(sender);
    Console.WriteLine($"Received {buffer.Length} bytes from {sender}");
};

socket.Connected += (sender) =>
{
    Console.WriteLine($"{sender} is connected");
};

Notes

  • Supports .NET 8.0+
  • Cross-platform: Windows, Linux, macOS
  • STUN and public IP detection supported externally

About

Reliable UDP communication with TCP-like delivery guarantees — packet fragmentation, reassembly, and ACK-based retransmission over UDP.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages