C++ 中的简单网络服务器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2055175/
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
Simple webserver in C++?
提问by H4cKL0rD
Is there any reference or library that would create a webserver (help)? (in C++)
是否有任何参考或库可以创建网络服务器(帮助)?(在 C++ 中)
采纳答案by Filip Ekberg
You might find this interesting (SO, via Wayback Machine),it's how you create a webserver in C which is not totally different from C++.
您可能会发现这很有趣(SO,通过 Wayback Machine),这就是您在 C 中创建网络服务器的方式,这与 C++ 并没有完全不同。
However if you are using Windows and C++ you might want to look at A simple Webserver in C++
但是,如果您使用的是 Windows 和 C++,则可能需要查看A simple Webserver in C++
回答by Ricardo Mu?oz
You can use Boost Asioto do that, see the HTTP server examples
您可以使用Boost Asio来做到这一点,请参阅 HTTP 服务器示例
回答by thinlizzy
there is a new C++11 wrapper to mongoose here: https://code.google.com/p/mongoosecpp/
这里有一个新的 C++11 包装器用于猫鼬:https: //code.google.com/p/mongoosecpp/
mongoose is a simple webserver for C code. This wrapper uses C++11 features on mongoose structs (example: std::function for callbacks, instead of function pointers) and also provides a page dispatcher that matches url patterns to std::functions
mongoose 是一个简单的 C 代码网络服务器。这个包装器在 mongoose 结构上使用 C++11 特性(例如:std::function 用于回调,而不是函数指针),还提供了一个页面调度程序,将 url 模式匹配到 std::functions
回答by Rob
回答by Jeremy Morgan
With all the awesome options out there, it seems like reinventing the wheel. But to answer your question, here is a small tutorial on building a simple webserver in C++. Might be worth a try. One big advantage I can see from doing this is low overhead. Good luck with your project.
有了所有很棒的选择,这似乎是在重新发明轮子。但是为了回答你的问题,这里有一个关于用 C++ 构建简单网络服务器的小教程。也许值得尝试一下。我可以从这样做中看到的一大优势是低开销。祝你的项目好运。