Any NIO frameworks for .NET? [closed]

匿名 (未验证) 提交于 2019-12-03 01:52:01

问题:

Are there any non-blocking IO frameworks for .NET?

I am looking for something similar to what Apache Mina and JBoss Netty provides for Java: a framework for implementing highly scalable servers - not just the low-level support that the .NET framework provides.

EDIT: To better explain what I would like to see, here is a basic example of what you can do with Mina:

In Mina I can implement a ProtocolDecoder like this:

public class SimpleDecoder extends CumulativeProtocolDecoder {   protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {     if (in.remaining() 

And a CommandHandler like this:

public abstract class CommandHandler extends IoHandlerAdapter{   public void messageReceived(IoSession session, Object message) throws IOException, CloneNotSupportedException {     Command command = (Command) message;     // Handle command. Probably by putting it in a workqueue.   } } 

If I start the server by calling

CommandHandler handler = new CommandHandler(); NioSocketAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("protocol", new ProtocolCodecFilter(new SimpleDecoder(false))); acceptor.setLocalAddress(new InetSocketAddress(port)); acceptor.setHandler(handler); acceptor.bind(); 

I will get a non-blocking server.

It will run a single (or at least just a few) threads, cycling through all incoming connections, gathering data from the sockets, and call SimpleDecoder.doDecode() to see if it has a complete command on the connection. Then it will pass the command to CommandHandler.messageReceived(), and I can take over the processing.

回答1:

You can take a look at SuperSocket, http://supersocket.codeplex.com/ It may not be strong like Mina and Netty, but it is kind of simple framework you can use easily.



回答2:

There is the XF.Server, which this question says is flaky. This last question offers advice about how to write high performing networking code in .NET (use async sockets, etc.)

There's also a preview of C# Network Programming on Google Books which discusses, among other things, asynchronous socket calls.

This MSDN article is also interesting, but gets you no closer to an actual framework.



回答3:

You can use Mina directly in .Net via ikvm.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!