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. Repository: https://github.com/alec1o/netly Documentation: https://netly.docs.kezero.com Fork me: https://github.com/alec1o/Netly
$ dotnet add package NetlyNetly 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.
See the documentation here!
| 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 |
# 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
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();
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();
Below are some missing features that are planned to be added in later versions.