I know about projects like Edge.js which allow for C# and Node.js connectivity, but I'm talking about something different. Is there a library for C#, that allows you to build scalable, non-blocking I/O, single threaded, async event servers in C#, similar to the servers you can build with Node.js? A library that also has the unique event model of Node.js, single threaded for user code, multi threaded for file/network events and native code (correct me if I'm wrong). Of course I know about ASP and WCF, and OSS projects like this , but I'm looking for something that gives you performance comparable to Node.js, a kind of Node.js port to C#. Do you know of any such library, and what would it take to build it?
Single threaded or multi threaded?
If you want a single threaded managed process that does all its work using APC and completion ports, you are going to have to hand code it. Building it would be risky and tricky. -- Sam Salton
Obivously, being single threaded makes code easier to write since you don't need to work with locks and mutexes. There's just one thread reading/modifying program state data which keeps things simple. All calculations occur on seperate threads and return to the main thread when the results are ready. All file/network events branch out and return to the main thread after the op is complete.
Related but different questions:
Probably useful projects:
I already posted this to your first related question, which may answer your question as well:
Here is an open-source example written in VB.NET and C#:
https://github.com/perrybutler/dotnetsockets/
It uses Event-based Asynchronous Pattern (EAP), IAsyncResult Pattern and thread pool (IOCP). It will serialize/marshal the messages (messages can be any native object such as a class instance) into binary packets, transfer the packets over TCP, and then deserialize/unmarshal the packets at the receiving end so you get your native object to work with. This part is somewhat like Protobuf or RPC.
It was originally developed as a "netcode" for real-time multiplayer gaming, but it can serve many purposes. Unfortunately I never got around to using it. Maybe someone else will.
The source code has a lot of comments so it should be easy to follow. Enjoy!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.