SAEA.Socket高性能 sockets 网络框架
SAEA.Socket 是一个 IOCP 高性能 sockets 网络框架,基于 dotnet standard 2.0;Src 中含有其使用场景,例如大文件传输、websocket client and server、高性能消息队列、rpc、redis 驱动、httpserver、MQTT、Mvc、DNS、消息服务器等。
- [√] IOCP
- [√] FileTransfer
- [√] FTP
- [√] MessageSocket
- [√] QueueSocket
- [√] MVC
- [√] RPC
- [√] Websocket
- [√] RedisDrive
- [√] MQTT
- [√] DNS
引用组件
引用组件,可以在 nuget 中搜索 saea,或者直接输入命令
Install-Package SAEA.Sockets -Version 6.0.0.2
例子
用于自定义协议的 SAEA.Sockets
JT808协议
测试项目为SAEA.SocketsTest,其中演示了使用三方协议(JT808)来如何扩展 IContext、IUnpacker 解码、编码的方式接入 SAEA.Sockets
FileTransfer
saea.filesocket 用法
var fileTransfer = new FileTransfer(filePath); fileTransfer.OnReceiveEnd += _fileTransfer_OnReceiveEnd; fileTransfer.OnDisplay += _fileTransfer_OnDisplay; fileTransfer.Start(); //send file fileTransfer.SendFile(string fileName, string ip)
FTP
saea.ftp 用法
saea.ftpclient
var client = new FTPClient(ip, port, username, pwd); client.Ondisconnected += _client_Ondisconnected; client.Connect(); var path = client.CurrentDir(); client.Upload(filePath, (o, c) => { size = c; _loadingUserControl.Message = $"正在上传文件:{fileName},{(o * 100 / c)}%"; }); client.Download(fileName, Path.Combine(filePath, fileName), (o, c) => { _loadingUserControl.Message = $"正在下载文件:{fileName},{(o * 100 / c)}%"; });
saea.ftpserver
_serverConfig.IP = ip; _serverConfig.Port = port; FTPServerConfigManager.Save(); var ftpServer = new FTPServer(_serverConfig.IP, _serverConfig.Port, _serverConfig.BufferSize); ftpServer.OnLog += _ftpServer_OnLog; ftpServer.Start();
QueueTest
saea.queue 服务器使用
var server = new QServer(); server.Start();
saea.queue producer 用法
var ipPort = "127.0.0.1:39654"; QClient producer = new QClient("productor_" + Guid.NewGuid().ToString("N"), ipPort); producer.OnError += Producer_OnError; producer.OnDisconnected += Client_OnDisconnected; producer.Connect(); producer.Publish(topic, msg);
saea.queue consumer 使用
var ipPort = "127.0.0.1:39654"; QClient consumer = new QClient("subscriber_" + Guid.NewGuid().ToString("N"), ipPort); consumer.OnMessage += Subscriber_OnMessage; consumer.OnDisconnected += Client_OnDisconnected; consumer.Connect(); consumer.Subscribe(topic);
评论