A simple to use TCP and UDP networking library for .NET, designed to be flexible, scalable and FAST.
Get involved and join us in Discord (https://discord.gg/NdEqhAe)
- .NET Standard 2.0
- TCP
- UDP
- Socket Pooling
- Object Pooling
- Process thousands of requests per second
- Dependency Injection using Micrsoft.Extensions.DependencyInjection.ServiceCollection
- Logging using Microsoft.Extensions.Logging
- Works with Unity Game Engine
V3 is currently in pre-release. Get the latest build below. NuGet Package Manager
Install-Package Networker -IncludePrerelease
You must then install one of the following formatters
Networker.Formatter.ZeroFormatter
Install-Package Networker.Formatter.ZeroFormatter
Networker.Formatter.ProtoBufNet
Install-Package Networker.Formatter.ProtoBufNet
Get started with this tutorial written by the library developer Mark Eastwood
Creating a server is easy..
var server = new ServerBuilder()
.UseTcp(1000)
.UseUdp(5000)
.RegisterPacketHandlerModule<DefaultPacketHandlerModule>()
.RegisterPacketHandlerModule<ExamplePacketHandlerModule>()
.UseZeroFormatter()
.ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddConsole();
loggingBuilder.SetMinimumLevel(
LogLevel.Debug);
})
.Build();
server.Start();
You can handle a packet easily using dependency injection, logging and built-in deserialisation.
public class PingPacketHandler : PacketHandlerBase<PingPacket>
{
private readonly ILogger logger;
public PingPacketHandler(ILogger<PingPacketHandler> logger)
{
this.logger = logger;
}
public override async Task Process(PingPacket packet, ISender sender)
{
this.logger.Debug("Received a ping packet from " + sender.EndPoint);
}
}
Version 3 included a large rewrite and various breaking changes. To use V2 please see V2 Branch