Netly

2025-12-07 0 618
Active development occurs on the \’dev\’ branch. For the stable release, refer to the \’main\’ branch.

Netly version 4 is now available! Experience the new way of interacting with Netly. See more

Your star on Netly brightens our journey and makes a real impact!
Every like/star is a powerful boost that drives us forward.
? Thank you for your incredible support!

Netly


powered by ALEC1O

Project

Get basic information about this project called Netly

Overview
Netly is a robust C# socket library designed to streamline network communication. It offers comprehensive support for multiple protocols, including HTTP, TCP, SSL/TLS, UDP, Reliable UDP (RUDP), and WebSocket. This versatility makes Netly an excellent choice for developing a wide range of applications, from multiplayer games and chat systems to real-time data exchanges.

Website
Repository: github.com/alec1o/netly
Documentation: netly.docs.kezero.com

Sponsor

  
Keep Netly alive – sponsor it on Buy Me a Coffee.


  
KeZero sponsor Netly with hosting infrastructure and website domain.


  
Netly receives JetBrains\’ IDE for free, Thanks to their generous sponsorship.

Supporter
Why Contribute to Netly?
  • Transform Network Communication:
    Join us in revolutionizing how software communicates. Your contributions will help build a library that sets new standards for efficiency and reliability.
  • Advance Your Career:
    Engage with innovative projects, solve complex problems, and collaborate with experts. Your involvement will sharpen your skills and expand your professional network.
  • Share Your Ideas:
    Whether you\’re a seasoned developer or just starting out, your ideas are valuable. Contribute thoughts and suggestions to shape the future of Netly and drive innovation.

Installing

Official publisher

Nuget Unity Asset Store
Install on Nuget Install on Asset Store

Versions

Notable changes

v1.x.x v2.x.x v3.x.x v4.x.x
Legacy Legacy Stable Latest
TCP Support TCP with Message Framing support TCP with TLS/SSL support HTTP client and server support
UDP Support TCP and UDP performance increase UDP with connection (timeout response) Reliable UDP (RUDP) client and server support
New Message Framing protocol and performance increase WebSocket client and server support
Upgrade to Byter 2.0 Upgrade to Byter 4.0
Docsify as documentation framework Documentation improvement by Docusaurus and DocFxMarkdownGen
Syntax and internal improvement
XML comments improvement

Integrations

Technical descriptions about integrations

List of tested platforms

  • .NET (SDK)
  • Mono (SDK)
  • Unity (Engine)
  • Operating system (OS)

    • Android
    • iOS
    • Windows
    • Linux
    • macOS

      Notice: This library might run on all devices. If it doesn\’t work on any device, it
      should be considered a bug and reported.






Dependencies

Byter
Build

Build dependencies
  • Git
  • .NET
Build step-by-step
# 1. clone project
$ git clone \"https://g*ithu**b.com/alec1o/Netly\" netly

# 2. build project
$ dotnet build \"netly/\" -c Release -o \"netly/bin/\"

# NOTE:
# Netly.dll require Byter.dll because is Netly dependency
# Netly.dll and Byter.dll have on build folder <netly-path>/bin/

Features

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

  • N/A

Examples

Code highlights

TCP
? Client
using Netly;

TCP.Client client = new TCP.Client(framing: true);
client.On.Open(() =>
{
    printf(\"connection opened\");
});

client.On.Close(() =>
{
    printf(\"connetion closed\");
});

client.On.Error((exception) =>
{
    printf(\"connection erro on open\");
});

client.On.Data((bytes) =>
{
    printf(\"connection receive a raw data\");
});

client.On.Event((name, data) =>
{
    printf(\"connection receive a event\");
});

client.On.Modify((socket) =>
{
    printf(\"called before try open connection.\");
});

client.On.Encryption((certificate, chain, errors) =>
{
    // Only if client.IsEncrypted is enabled
    printf(\"validate ssl/tls certificate\");
    // return true if certificate is valid
    return true;
});
// open connection if closed
client.To.Open(new Host(\"127.0.0.1\", 8080));

// close connection if opened
client.To.Close();

// send raw data if connected
client.To.Data(new byte[2] { 128, 255 });
client.To.Data(\"hello world\", NE.Encoding.UTF8);

// send event if connected
client.To.Event(\"name\", new byte[2] { 128, 255 });
client.To.Event(\"name\", \"hello world\", NE.Encoding.UTF8);

// enable encryption (must call before client.To.Open)
client.To.Encryption(true);
? Server
using Netly;

TCP.Server server = new TCP.Server(framing: true);
server.On.Open(() =>
{
    printf(\"connection opened\");
});

server.On.Close(() =>
{
    printf(\"connection closed\");
});

server.On.Error((exception) =>
{
    printf(\"connection error on open\");
});

server.On.Accept((client) =>
{
    client.On.Modify((socket) =>
    {
        printf(\"modify client socket e.g Enable NoDelay\");
    });

    client.On.Open(() =>
    {
        printf(\"client connected\");
    });

    client.On.Data((bytes) =>
    {
        printf(\"client receive a raw data\");
    });

    client.On.Event((name, bytes) =>
    {
        printf(\"client receive a event\");
    });

    client.On.Close(() =>
    {
        printf(\"client disconnected\");
    });
});

server.On.Modify((socket) =>
{
    printf(\"called before try open connection.\");
});
// open connection
server.To.Open(new Host(\"1.1.1.1\", 1111));

// close connection
server.To.Close();

// enable encryption support (must called before server.To.Open)
server.To.Encryption(enable: true, @mypfx, @mypfxpassword, SslProtocols.Tls12);

// broadcast raw data for all connected client
server.To.DataBroadcast(\"text buffer\");
server.To.DataBroadcast(new byte[] { 1, 2, 3 });

// broadcast event (netly event) for all connected client
server.To.EventBroadcast(\"event name\", \"text buffer\");
server.To.EventBroadcast(\"event name\", new byte[] { 1, 2, 3 });
UDP
? Client
using Netly;

UDP.Client client = new UDP.Client();
client.On.Open(() =>
{
    printf(\"connection opened\");
});

client.On.Close(() =>
{
    printf(\"connection closed\");
});

client.On.Error((exception) =>
{
    printf(\"connection error on open\");
});

client.On.Data((bytes) =>
{
    printf(\"connection received a raw data\");
});

client.On.Event((name, eventBytes) =>
{
    printf(\"connection received a event\");
});

client.On.Modify((socket) =>
{
   printf(\"called before try open connection.\");
});
// open connection if closed
client.To.Open(new Host(\"127.0.0.1\", 8080));

// close connection if opened
client.To.Close();

// send raw data if connected
client.To.Data(new byte[2] { 128, 255 });
client.To.Data(\"hello world\", NE.Encoding.UTF8);

// send event if connected
client.To.Event(\"name\", new byte[2] { 128, 255 });
client.To.Event(\"name\", \"hello world\", NE.Encoding.UTF8);
? Server
using Netly;

UDP.Server server = new UDP.Server();
server.On.Open(() =>
{
    printf(\"connection opened\");
});

server.On.Close(() =>
{
    printf(\"connection closed\");
});

server.On.Error((exception) =>
{
    printf(\"connection error on open\");
});

server.On.Accept((client) =>
{
    client.On.Open(() =>
    {
        printf(\"client connected\");
    });

    client.On.Close(() =>
    {
        // Only if use connection is enabled.
        printf(\"client disconnected\");
    });

    client.On.Data((bytes) =>
    {
        printf(\"client received a raw data\");
    });

    client.On.Event((name, bytes) =>
    {
        printf(\"client received a event\");
    });
});
// open connection
server.To.Open(new Host(\"127.0.0.1\", 8080));

// close connection
server.To.Close();

// broadcast raw data for all connected client
server.To.DataBroadcast(\"text buffer\");
server.To.DataBroadcast(new byte[] { 1, 2, 3 });

// broadcast event (netly event) for all connected client
server.To.EventBroadcast(\"event name\", \"text buffer\");
server.To.EventBroadcast(\"event name\", new byte[] { 1, 2, 3 });
HTTP
? Client
using Netly;

HTTP.Client client = new HTTP.Client();

// add http header for request
client.Headers.Add(\"Content-Type\", \"json\");
client.Headers.Add(\"Token\", \"ImGui.h\");

// add http url queries e.g: https://www.*al**ec1o.com/?page=about&version=4
client.Queries.Add(\"page\", \"about\");
client.Queries.Add(\"version\", \"4\");

// set request timeout (ms) default 15s (15000ms), 0 or negative value means infinite timeout.
client.Timeout = 6000; // 6s

// is opened: while is requesting
bool isFetching = client.IsOpened;
HttpClient http = null;

// called before try connect to server
// modify the HttpClient object
client.On.Modify((HttpClient instance) =>
{
    http = instance;
});

// connection is opened and fetch server.
client.On.Open((response) =>
{
    // you can use \"http\" instance on this scope (isn\'t null)
    if (http.<foo> == <bar>) { ... }
});

// erro on fetch, it can be timeout or whatever error
// but if you receives error it mean the operation is called or done
client.On.Error((Exception exception) =>
{
    Ny.Logger.PushError(exception);
});

// connection is closed with fetch server.
client.On.Close(() =>
{
     if (http.<bar> == <foo>) { ... }
});
// used to fetch a server
client.To.Open(\"method e.g GET\", \"url\", \"body, allow null\");

// used for cancel opened request
client.To.Close();
? Server
using Netly;

HTTP.Server server = new HTTP.Server();

// return true if server is serve http context
bool isServe = server.IsOpened;
server.On.Open(() =>
{
    // http server opened
});
server.On.Close(() =>
{
    // http server closed
});

server.On.Error((exception) =>
{
    // http server open error
});

server.On.Modify((httpListener) =>
{
    // HttpListener instance, called before try open connection.
});

// Open http server connection
server.To.Open(new Uri(\"http://127.**0.*0.1:8080/\"));

// Close http server connection
server.To.Close();
Map

下载源码

通过命令行克隆项目:

git clone https://github.com/alec1o/Netly.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 开发教程 Netly https://www.zuozi.net/31238.html

常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务