Netly 3.1.0
dotnet add package Netly --version 3.1.0
NuGet\Install-Package Netly -Version 3.1.0
<PackageReference Include="Netly" Version="3.1.0" />
paket add Netly --version 3.1.0
#r "nuget: Netly, 3.1.0"
// Install Netly as a Cake Addin #addin nuget:?package=Netly&version=3.1.0 // Install Netly as a Cake Tool #tool nuget:?package=Netly&version=3.1.0
About
Netly is a flexible socket library built on c-sharp. It is compatible with (Android, iOS, Linux, Windows...)
Documentation
Netly docs (HERE)
Install
Official publisher
Nuget | Unity Asset Store |
---|---|
Install on Nuget | Install on Asset Store |
Sponsor and Supporter
Well, this project is open source and only development can be supported by suggestions for improvements, bug reports or the like. (for those who want to financially support this resource is not available at this time)
Versions
Notable changes
v1 (old) | v2 (old) | v3 (stable) | v4 (nonexistent) |
---|---|---|---|
TCP (client/server) | TCP/IP Message Framing | TLS/SSL (client/server) | Websocket (client/server) |
UDP | TCP/UDP performance improvement | Include docs/sample (SSL/TLS) | Include docs/sample (Websocket) |
Message Framing memory and performance improve |
|||
Message Framing new protocol |
|||
UDP impl connection with udp (ping/timeout) |
|||
collaborative documentation docsify |
|||
Byter 2.0 |
List of tested platforms
Feature
Below are some missing features that are planned to be added in later versions.
- Websocket (v4)
Dependency
Build
Build dependencies
Build step-by-step
# 1. clone repository
$ git clone "https://github.com/alec1o/netly" netly/
# 2. build netly project
$ dotnet build -C Release netly/
# DLL_PATH: netly/src/bin/netstandard2.0/Netly.dll
# 3. For use Netly.dll you need Byter.dll (a Netly dependecy)
$ git clone "https://github.com/alec1o/byter" byter/
# 4. build byter project
$ dotnet build -C Release byter/
# DLL_PATH: byter/src/bin/netstandard2.0/Byter.dll
# WARNING: when use Netly.dll must include Byter.dll
Demo
TcpClient
Syntax
using Netly;
using Netly.Core;
var client = new TcpClient(framing: true);
// Enable SSL/TLS (onValidate delegate is optional)
client.UseEncryption(enableEncryption: true, onValidate: null);
client.OnOpen(() =>
{
// client connected
});
client.OnClose(() =>
{
// client disconnected
});
client.OnError((Exception exception) =>
{
// connection close because: 1.Error on connecting, 2.Invalid framing data
});
client.OnData((byte[] data) =>
{
// raw data received
});
client.OnEvent((string name, byte[] data) =>
{
// event received (event use netly protocol)
});
client.OnModify((Socket socket) =>
{
// you can modify socket, called before open connection
});
client.Open(new Host("127.0.0.1", 8080));
TcpServer
Syntax
using Netly;
using Netly.Core;
var server = new TcpServer(framing: true);
// Enable SSL/TLS
byte[] pfxCert = <DO_SOMETHING>;
string pfxPass = <DO_SOMETHING>;
server.UseEncryption(pfxCert, pfxPass, SslProtocols.Tls13); // TLS v1.3
server.OnOpen(() =>
{
// server start listen
});
server.OnClose(() =>
{
// server stop listen
});
server.OnError((Exception exception) =>
{
// error on start listen (connecting)
});
server.OnData((TcpClient client, byte[] data) =>
{
// a client receive raw data
});
server.OnEvent((TcpClient client, string name, byte[] data) =>
{
// a client receive event (event use netly protocol)
});
server.OnEnter((TcpClient client) =>
{
// a client connected on server
client.OnClose(() =>
{
// alternative of: TcpServer.OnClose
});
client.OnData(() =>
{
// alternative of: TcpServer.OnData
});
client.OnEvent(() =>
{
// alternative of: TcpServer.OnEvent
});
});
server.OnExit((TcpClient client) =>
{
// a client disconnected from server
});
server.OnModify((Socket socket) =>
{
// you can modify socket, called before listen and bind a port
});
server.Open(new Host("127.0.0.1", 8080));
Product | Versions 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. |
.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 was computed. |
.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. |
-
.NETStandard 2.0
- Byter (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Note
[+] Added
[-] Removed
[!] Fixed
[>] Updated
3.0.0
[+] SSL/TLS protocol
[+] Include docs/sample (SSL/TLS)
[+] New docs (Gitbook -> Docsify)
[>] New MessageFraming protocol
[>] Message Framing memory and performance improve
[>] Udp set max buffer size
[>] Udp connection detection (timeout/ping-pong)
[!] MainThread null reference exception
[>] Byter 2.0
3.1.0
[!] Fix auto-disconnect because socket timeout. set -1 (infinite) as default timeout.