sga*_*a62 2 c++ port boost http boost-asio
我正在使用boost :: asio库.
我一直在尝试在端口80上运行我的服务器,但无法让它这样做.以下是我的代码中的罪魁祸首,评论中的结果如下:
// This runs fine, and the webpage is visible on localhost:8000
tcp::acceptor a(*io_service, tcp::endpoint(tcp::v4(), 8000));
// This throws an error (at this line)
tcp::acceptor a(*io_service, tcp::endpoint(tcp::v4(), 80));
// This runs fine, but the webpage is NOT visible on localhost or localhost:80
tcp::acceptor a(*io_service, tcp::endpoint());
Run Code Online (Sandbox Code Playgroud)
我注意到端点只接受四位数的端口号.这可能与它有关吗?
如何在端口80上看到我的页面运行?谢谢!
我不确定它在Windows上是如何工作的,但在Unix(包括Linux)上,1024以下的端口只能受特权进程的约束.尝试运行它root.当然,您应该setuid在打开端口后放弃权限(使用系统调用).
| 归档时间: |
|
| 查看次数: |
216 次 |
| 最近记录: |