可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am thinking of the next steps for a project I have written. It is currently a desktop application that controls a serial port device.
I am considering allowing browser clients to connect to some process to get "near real time" updates about the state, etc of the device. Possibly also allowing control from a browser client.
I'd rather not write my own webserver from scratch and this would be a very scaled down web server.
Any suggestions on where to look?
I'd prefer C++ or C# implementation.
回答1:
If you are running on Windows, use http.sys. It is a lightweight web server that is exposed through the .NET framework.
http://mikehadlow.blogspot.com/2006/07/playing-with-httpsys.html
回答2:
I don't know any C# http server, but you could make your own pretty quickly (see http://www.codeplex.com/webserver).
As suggested, lighthttpd might do the trick.
I'd also recommend simpleweb, which is a very light and powerful http server written in Java.
回答3:
I've heard good things from a friend about lighthttpd
回答4:
nginx is very lightweight and very scalable (e.g. see
Wordpress's story for a high-profile case). POSIX-only.
回答5:
Check out my webserver project: http://www.codeplex.com/webserver
It contains a lite branch for a minimal one.
回答6:
Consider taking a look at the System.Net.HTTPListener class. It implements a HTTP listener which makes it very easy to respond to HTTP requests from clients. Since you don't need a full-fledged HTTP server, that is probably the way to go!
回答7:
A couple more suggestions:
- NancyFX (look for self host)
- Kayax
回答8:
Here's another alternative I wrote last year and and has served me well.
EmbedIO: https://github.com/unosquare/embedio
I use it mostly to create RESTful services on the Raspberry Pi (soft-float).
It's MIT licensed too.
回答9:
When you run a web project from Visual Studio, you are typically running it via Cassini2. That is a downloadable project as well.
Otherwise, if you want something smaller, you can look at Indy 10 library (open source), which is a complete set of networking apis. You could probably write your own web server fairly quickly with that.
Or, NSoftware also has some networking apis. They are commercial, but well documented, and I've had good luck with their support (but it has been a while for that).
回答10:
Since you're not writing it yourself, does it have to be a minimal server? Apache and related might serve your purpose. It's heavyweight, but without knowing more of your requirements that might or might not be a problem.
回答11:
Look at Codeprpject Website
there are many open-source and simple webserver
Create your own Web Server using C#
Simple HTTP Server in C#
回答12:
I don't know if will fit your project but http://www.tntnet.org/ looks promising. Alternatively, you can look for a http server library which you can add your custom code to build a web server with application embedded. There are many (like libmicrohttpd), that it is not worth enumerating here without knowing your project.
回答13:
You can try nodejs to build a webserver as well.
There are examples available on implementing a simple one