ASP.NET as server app - questions before I'm getting into it
Earlier on I've implemented a custom C++ server from scratch, something which is nice and fun to do but is very time-consuming.
So I've heard about "servlet" of Java which sounds like something I'm looking for for my next project.
I'm looking at ASP.NET to be used as a servlet because it's pretty much mature in terms of networking capabilities and programming features and I can write code for it in C# which is a language I already know and feels good with.
Anyway before getting into it I'd like to get concise answers regarding some of the capabilities that ASP.NET may provide me with.
My client application is Flash-based and has nothing to do with XML or HTTP protocols (raw sockets).1) Can I accept raw (in terms of protocol) socket connections and keep them alive as long as needed?
2) How hard/complicated is it to apply AES encryption over a connected socket? 3) Can I have a "shared", in-memory, objects, like lists, over the application's instance? 4) Can I get one message from client X and send a copy/reply/report (on the fly) to client Y, without using a database or anything like that? This question suggests question #5. 5) Can I identify a connection by its memory address or object address, so I can refer to it directly? 6) Can my application be distributed over several servers? 7) How hard/complicated is it to scale such an application? For 10 concurrent connections there's no problem but for 50,000 I can surely expect load issues. 8) Finally, the most important question which probably has the most complex answer: How flexible is the environment from开发者_运维问答 a programmer perspective? I mean, can I control events such as "on_connect", "on_disconnect" and stuff like that? How hard would it be to access connection Y from connection X's event (such as "on_data_received")?ASP.Net is more like JSP than Java Servlets as it requires a web server to run. Typically IIS is used since Microsoft has built in ASP.Net support there, but it's possible to run ASP.Net on other web servers. As a web server product it's all HTTP and therefor connectionless. Based on your questions 1, 2, 4, 5 and 8 this may be a deal-killer for you.
If you can code your Flash application to manage itself with HTTP/HTTPS connections then using ASP.Net to build out web services that your app can use is a decent option. IIS is mature and can scale out nicely (q's 6 & 7). It also has an application-level store that you can use (q3). Of course each server in a farm would have its own copy.
It's possible to implement your own server in C# with a lot less effort than in C++, but it's still a time consuming endeavor. The TcpListener class in System.Net.Sockets would be the starting point if you chose to go that route.
I would go with Client/Server .NET application, not ASP.NET as it's out of its "scope".
Unless one of the demands is to have public website?
精彩评论