【发布时间】:2014-06-15 17:20:21
【问题描述】:
我正在使用boost::asio 库。
我一直试图在端口 80 上运行我的服务器,但无法让它这样做。以下是我的代码中的罪魁祸首,结果在 cmets 中:
// 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());
我注意到端点只接受四位数的端口号。这可能与它有关吗?
如何查看我的页面在端口 80 上运行?谢谢!
【问题讨论】:
-
哪个操作系统?
-
1024 以下的端口保留给系统使用,您必须拥有提升的权限才能打开这些端口。
-
@sgarza62:这是一个 unix 衍生产品,所以是的,您只能以
root绑定到 1024 以下的端口。
标签: c++ http boost port boost-asio