
今天给大家推荐一个NET上的轻量级高性能网络程序框架Mina.NET。支持TCP、UDP和串口等多种传输通道,能够帮助开发者快速地开发高伸缩性的应用程序。
Mina.NET是Apache MINA的.Net实现,它通过异步套接字提供了一个抽象的事件驱动的异步 API,以支持各种传输,例如 TCP/IP。
目录结构

Mina.NET 特点
Mina.NET优势
适用场景
Mina.NET使用
IoAcceptor acceptor = new AsyncSocketAcceptor();
acceptor.FilterChain.AddLast("logger", new LoggingFilter());
acceptor.FilterChain.AddLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Encoding.UTF8)));
acceptor.ExceptionCaught += (o, e) => Console.WriteLine(e.Exception);
acceptor.SessionIdle += (o, e) => Console.WriteLine("IDLE " + e.Session.GetIdleCount(e.IdleStatus));
acceptor.MessageReceived += (o, e) =>
{
String str = e.Message.ToString();
// "Quit" ? let's get out ...
if (str.Trim().Equals("quit", StringComparison.OrdinalIgnoreCase))
{
e.Session.Close(true);
return;
}
// Send the current date back to the client
e.Session.Write(DateTime.Now.ToString());
Console.WriteLine("Message written...");
};
acceptor.Bind(new IPEndPoint(IPAddress.Any, 8080));资源获取方式
https://github.com/longshine/Mina.NET