HassaanAkbar / AchiSocket

Fast, asynchronous and event-driven socket communication for .NET Standard (.NET Core, Mono, .Net Framework)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AchiSocket

AchiSocket is a fast TCP communication library to make socket communication simple and reliable. It is asynchronous, event-driven and handles reconnection and keep-alive automatically.

Usage

Creating a Server

var server = new AchaServer(5900);
            server.StartListening(socket =>
            {
                Console.WriteLine("Client connected");
                socket.StartReceive(packet =>
                {
                    Console.WriteLine("Received: " + packet.GetBody().Length);
                    
                });
            });

Connecting as a Client

            var _client = new AchaClient(ip, port);
            _client.Connect(async socket => 
            {
                if (socket == null)
                {
                    Console.WriteLine("Failed to connect");
                    return;
                }
                await socket.SendAsync(new TextPacket("Hello from client"));
            });

About

Fast, asynchronous and event-driven socket communication for .NET Standard (.NET Core, Mono, .Net Framework)


Languages

Language:C# 100.0%