Longbow.UdpSocket
11.0.0
Prefix Reserved
dotnet add package Longbow.UdpSocket --version 11.0.0
NuGet\Install-Package Longbow.UdpSocket -Version 11.0.0
<PackageReference Include="Longbow.UdpSocket" Version="11.0.0" />
<PackageVersion Include="Longbow.UdpSocket" Version="11.0.0" />
<PackageReference Include="Longbow.UdpSocket" />
paket add Longbow.UdpSocket --version 11.0.0
#r "nuget: Longbow.UdpSocket, 11.0.0"
#:package Longbow.UdpSocket@11.0.0
#addin nuget:?package=Longbow.UdpSocket&version=11.0.0
#tool nuget:?package=Longbow.UdpSocket&version=11.0.0
Longbow.UdpSocket
Longbow.UdpSocket is a UDP socket communication library based on the .NET platform, providing a simple and easy-to-use API for asynchronous TCP communication. It supports automatic receiving, auto-reconnect, packet adapters, and more, making it suitable for building high-performance network communication applications.
🚀 Features
- Asynchronous Communication: Uses
ValueTaskfor high-performance asynchronous TCP communication. - Automatic Receiving: Supports automatic data stream reception, simplifying data processing logic.
- Auto-Reconnect: Automatically attempts to reconnect when the connection is lost.
- Packet Handler: Handles sticky packets and packet splitting issues.
- Packet Adapter: Supports custom packet parsing logic.
- Logging Support: Optional logging functionality for debugging and monitoring.
- Dependency Injection Integration: Seamlessly integrates with .NET dependency injection frameworks.
📦 Installation
You can install Longbow.UdpSocket via NuGet:
dotnet add package Longbow.UdpSocket
🛠️ Quick Start
1. Register Services
Register the service in Startup.cs or Program.cs:
services.AddUdpSocketFactory();
Then obtain or create a client instance via IUdpSocketFactory:
var factory = serviceProvider.GetRequiredService<IUdpSocketFactory>();
var client = factory.GetOrCreate("myClient", options =>
{
options.IsAutoReconnect = true;
});
Create a TCP Client and Connect to Server
using Longbow.UdpSocket;
var factory = serviceProvider.GetRequiredService<IUdpSocketFactory>();
var client = factory.GetOrCreate("myClient", options =>
{
options.IsAutoReconnect = true;
});
client.ReceivedCallback = async (data) =>
{
Console.WriteLine($"Received: {Encoding.UTF8.GetString(data)}");
};
await client.ConnectAsync(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8080));
Use Packet Adapter for Custom Data Formats
using Longbow.UdpSocket;
var factory = serviceProvider.GetRequiredService<IUdpSocketFactory>();
var client = factory.GetOrCreate("myClient", options =>
{
options.IsAutoReconnect = true;
});
// Set packet adapter
client.AddDataPackageAdapter<MockEntity>(new FixLengthDataPackageHandler(12), OnReceive);
// Connect to remote
await client.ConnectAsync(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8080));
Task OnReceive(MockEntity entity)
{
Console.WriteLine($"Received Entity: Id={entity.Id}, Name={entity.Name}");
return Task.CompletedTask;
}
[DataTypeConverter(Type = typeof(DataConverter<MockEntity>))]
class MockEntity
{
[DataPropertyConverter(Type = typeof(int), Offset = 4, Length = 2)]
public int Id { get; set; }
[DataPropertyConverter(Type = typeof(string), Offset = 6, Length = 4, EncodingName = "utf-8")]
public string? Name { get; set; }
}
🤝 Contributing
Contributions to code and documentation are welcome! Please refer to CONTRIBUTING.md for more information.
📄 License
This project is licensed under the Apache License. Please see the LICENSE file for details.
🔗 Related Links
📞 Contact
To contact the developers, please visit the project homepage or submit issues to Github Issues
| 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. 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. net11.0 is compatible. |
-
net10.0
- Longbow.Sockets (>= 11.0.0)
- Microsoft.Extensions.Options (>= 10.0.15)
-
net11.0
- Longbow.Sockets (>= 11.0.0)
-
net6.0
- Longbow.Sockets (>= 11.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
-
net7.0
- Longbow.Sockets (>= 11.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
-
net8.0
- Longbow.Sockets (>= 11.0.0)
- Microsoft.Extensions.Options (>= 10.0.15)
-
net9.0
- Longbow.Sockets (>= 11.0.0)
- Microsoft.Extensions.Options (>= 10.0.15)
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 |
|---|---|---|
| 11.0.0 | 91 | 11/11/2026 |