项目作者: IhyaCommunity

项目描述 :
Fast, asynchronous and event-driven socket communication for .NET Standard (.NET Core, Mono, .Net Framework)
高级语言: C#
项目地址: git://github.com/IhyaCommunity/AchiSocket.git
创建时间: 2018-07-28T16:01:32Z
项目社区:https://github.com/IhyaCommunity/AchiSocket

开源协议:

下载


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

  1. var server = new AchaServer(5900);
  2. server.StartListening(socket =>
  3. {
  4. Console.WriteLine("Client connected");
  5. socket.StartReceive(packet =>
  6. {
  7. Console.WriteLine("Received: " + packet.GetBody().Length);
  8. });
  9. });

Connecting as a Client

  1. var _client = new AchaClient(ip, port);
  2. _client.Connect(async socket =>
  3. {
  4. if (socket == null)
  5. {
  6. Console.WriteLine("Failed to connect");
  7. return;
  8. }
  9. await socket.SendAsync(new TextPacket("Hello from client"));
  10. });