ENet is cross-platform reliable UDP networking library written in C and ENet.Managed is an unofficial, managed wrapper for ENet available for .NET and it supports specific set of platforms. You can checkout ENet's repo here.
Take a look at examples folder.
- Supports AnyCPU targets
- Supports IPv6
- Provides async-await interface.
- It's cross-platform via .NET Standard
- It's available via NuGet package manager. (Here)
- You can set custom:
- compression method (not enabled by default, recommended to specify a compressor using
CompressWith*
) - checksum algorithm (not enabled by default, recommended to specify a checksum using
ChecksumWith*
) - heap allocator (by default ManagedENet forces ENet to use a custom allocator which is faster than malloc, take a look at
ENetManagedAllocator.cs
)
- compression method (not enabled by default, recommended to specify a compressor using
- Takes advantage of
Span<byte>
and friends to reduce GC allocations. - Provides nearly all features of ENet via managed API.
You can see how ENet performs compared to other libraries by taking look at these benchmarks.
Benchmarks for the wrapper itself are not available yet but it should have near native performance when optimizations are enabled.
Platform\Arch | X86 | X86_64 | ARM32 | ARM64 |
---|---|---|---|---|
Windows | Yes | Yes | Yes | - |
Linux | - | Yes | Yes | Yes |
Mac | - | Yes | - | - |
Linux binaries are built and statically linked against MUSL.
- This wrapper deploys ENet binaries to OS's temp folder and dynamically loads them, you can alter this behavior using
ENetStartupOptions
or by manually initializing ENet usingLibENet
class. - ENet binaries are built from https://github.com/moien007/enet
- ENet's checksum feature is disabled by default, it is highly recommended to use checksum to avoid receiving damaged packets.
ChecksumWithCRC32
enables ENet's builtin checksum feature.
- In case of consuming custom version of ENet you have to sync the data structures offsets with the wrapper.
ENetPeer.DisconnectNow
method will not generateENetEventType.Disconnect
.- If you use
SetUserData
extension methods you have to callUnsetUserData
when you done, otherwise memory leak will happen. - You can use
ENetPooledAllocator
in case if you want to make ENet use pooled buffers to reduce allocations.
You can contribute by reporting bugs and making pull requests.
MIT open-source license.