TH7903 / Netly

Netly is a open source socket library for c# (C-Sharp). It facilitates the use of socket (UDP and TCP, Client and Server) with which it is compatible (Android, iOS, macOS, Linux, Windows, ...) as long as it is compiled with its destination.

Home Page:https://netly.docs.kezero.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

powered by ALEC1O

About

Netly is a open source socket library for c# (C-Sharp). It facilitates the use of socket (UDP and TCP, Client and Server) with which it is compatible (Android, iOS, macOS, Linux, Windows, ...) as long as it is compiled with its destination.


Docs

See the documentation here!


Install

Official publisher
Nuget Unity Asset Store
Install on Nuget Install on Asset Store

Versions

Notable changes
v1 (old) v2 (current) v3 (nonexistent)
TCP client/server TCP/IP Message Framing SSL client/server
UDP client/server TCP/UDP performance improvement Add documentation and samples for SSL

Dependency


Build

  • Build dependencies

  • Build step-by-step

# 1. clone repository 
$ git clone "https://github.com/alec1o/netly.git"

# 2. open source directory 
$ cd netly/

# 5. restore dotnet project
$ dotnet restore

# 6. build dotnet project
$ dotnet build

List of tested platforms


Demo

  • Client

    Instance
    using Netly;
    using Netly.Core;
    
    // Example udp client instance
    var client = new UdpClient();
    
    // Example tcp client instance
    var client = new TcpClient();
    
    // Example host instance
    var host = new Host("127.0.0.1", 3000);    
    Usage
    client.OnOpen(() =>
    {
        // connection opened
    });
    
    client.OnClose(() =>
    {
        // connection closed
    });
    
    client.OnError((exception) =>
    {   
        // error on open connection
    });
    
    client.OnData((data) => 
    {
        // buffer/data received
    });
    
    client.OnEvent((name, data) =>
    {
        // event received: {name: event name} {data: buffer/data received} 
    });
    
    // open connection
    client.Open(host);
    
    // send data
    client.ToData(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9});
    
    // send event
    client.ToEvent("name", new byte[] { 1, 2, 3, 4, 5, 6});
    
    // close connection
    client.Close();
  • Server

    Instance
    using Netly;
    using Netly.Core;
    
    // Example tcp server instance
    var server = new TcpServer();
    
    // Example udp server instance
    var server = new UdpServer();
    
    // Example host instance
    var host = new Host("0.0.0.0", 3000);
    Usage
    server.OnOpen(() =>
    {
        // connection opened: server start listen client
    });
    
    server.OnClose(() =>
    {
        // connection closed: server stop listen client
    });
    
    server.OnError((exception) =>
    {
        // error on open connection
    });
    
    server.OnEnter((client) =>
    {
        // client connected: connection accepted
    });
    
    server.OnExit((client) =>
    {
        // client disconnected: connection closed
    });
    
    server.OnData((client, data) =>
    {
        // buffer/data received: {client: client instance} {data: buffer/data received} 
    });
    
    server.OnEvent((client, name, data) =>
    {
        // event received: {client: client instance} {name: event name} {data: buffer received} 
    });
    
    // open connection
    server.Open(host);
    
    // broadcast data to clients
    server.ToData(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9});
    
    // broadcast event to clients
    server.ToEvent("name", new byte[] { 1, 2, 3, 4, 5, 6});
    
    // close connection
    server.Close();

Currently missing feature

Below are some missing features that are planned to be added in later versions.

  • [SslClient and SslServer] Tcp protocol with SSL/TLS encryption.

About

Netly is a open source socket library for c# (C-Sharp). It facilitates the use of socket (UDP and TCP, Client and Server) with which it is compatible (Android, iOS, macOS, Linux, Windows, ...) as long as it is compiled with its destination.

https://netly.docs.kezero.com

License:MIT License


Languages

Language:C# 100.0%