C# 开源最小的网络服务器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/462184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 04:19:52  来源:igfitidea点击:

Open source minimal web server?

c#c++webserver

提问by Tim

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.

我更喜欢 C++ 或 C# 实现。

回答by Jonathan Allen

If you are running on Windows, use http.sys. It is a lightweight web server that is exposed through the .NET framework.

如果您在 Windows 上运行,请使用 http.sys。它是一个通过 .NET 框架公开的轻量级 Web 服务器。

http://mikehadlow.blogspot.com/2006/07/playing-with-httpsys.html

http://mikehadlow.blogspot.com/2006/07/playing-with-httpsys.html

回答by Wookai

I don't know any C# http server, but you could make your own pretty quickly (see http://www.codeplex.com/webserver).

我不知道任何 C# http 服务器,但是您可以很快地制作自己的服务器(请参阅http://www.codeplex.com/webserver)。

As suggested, lighthttpdmight do the trick.

正如建议的那样,lighthttpd可能会起作用

I'd also recommend simpleweb, which is a very light and powerful http server written in Java.

我还推荐simpleweb,它是一个用 Java 编写的非常轻巧且功能强大的 http 服务器。

回答by artificialidiot

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.

我不知道是否适合您的项目,但http://www.tntnet.org/看起来很有希望。或者,您可以查找 http 服务器库,您可以添加自定义代码以构建嵌入应用程序的 Web 服务器。有很多(例如 libmicrohttpd),在不了解您的项目的情况下不值得在此一一列举。

回答by Chris Brandsma

When you run a web project from Visual Studio, you are typically running it via Cassini2. That is a downloadable project as well.

从 Visual Studio 运行 Web 项目时,通常是通过 Cassini2 运行它。这也是一个可下载的项目。

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.

否则,如果你想要更小的东西,你可以查看 Indy 10 库(开源),它是一套完整的网络 api。你可以用它很快地编写你自己的 Web 服务器。

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).

或者,NSoftware 也有一些网络 API。它们是商业的,但有据可查,而且我在他们的支持下很幸运(但已经有一段时间了)。

回答by Adriano Varoli Piazza

I've heard good things from a friend about lighthttpd

我从朋友那里听说了关于lighthttpd 的消息

回答by David Thornley

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.

既然你不是自己写的,它是否必须是一个最小的服务器?Apache 和相关的可能符合您的目的。它是重量级的,但不知道您的更多要求可能是也可能不是问题。

回答by orip

nginxis very lightweight and very scalable (e.g. see Wordpress's storyfor a high-profile case). POSIX-only.

nginx非常轻量级且可扩展性非常高(例如,请参阅 Wordpress 的故事以了解一个引人注目的案例)。仅 POSIX。

回答by jgauffin

Check out my webserver project: http://www.codeplex.com/webserverIt contains a lite branch for a minimal one.

查看我的网络服务器项目:http: //www.codeplex.com/webserver它包含一个最小分支的 lite 分支。

回答by Loudenvier

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!

考虑查看 System.Net.HTTPListener 类。它实现了一个 HTTP 侦听器,这使得响应来自客户端的 HTTP 请求变得非常容易。由于您不需要成熟的 HTTP 服务器,这可能是要走的路!

回答by AminM

Look at Codeprpject Website
there are many open-source and simple webserver

看 Codeprpject 网站
有很多开源的简单的 webserver

Create your own Web Server using C#

使用 C# 创建您自己的 Web 服务器

Simple HTTP Server in C#

C# 中的简单 HTTP 服务器