如何在boost::asio服务器中使用端口80
How to use port 80 in a boost::asio server?
我正在使用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());
我注意到端点只接受四位数的端口号。这和它有关系吗?
如何查看在端口80上运行的页面?谢谢
我不确定它在Windows上是如何工作的,但在Unix(包括Linux(上,1024以下的端口只能由特权进程绑定。尝试将其作为root
运行。当然,您应该在打开端口后放弃权限(使用setuid
系统调用(。
相关文章:
- TCP 服务器的异步读取使用 boost::asio 打印客户端套接字发送的数据
- Boost Beast 异步服务器失败,断言失败:(id_ != T::id) 在多个 aync 调用中
- 为什么io_context在我的boost asio协同程序服务器中丢失
- boost beast websocket服务器也接受http连接
- 服务器和客户端同时使用BOOST-ASIO
- Boost-Beast 异步 Web 套接字 服务器-客户端异步读写 不在控制台上写入输出
- 插座无法接收数据?客户使用boost.asyio库编写.服务器用Python编写
- 浏览器将随机HTTP消息正文发送到我的boost.asio服务器.我可以更改此设置吗?
- 来自 boost 的 udp 服务器不适用于多线程,但仅在主线程上工作
- boost::asio http 服务器无法向 Postman 返回有效响应
- boost::asio::ip::tcp::iostream,先启动客户端,然后等待服务器
- 使用Valgrind时,偶尔的BOOST :: ASIO TCP服务器故障在Localhost上运行
- BOOST :: BEAST:带Websocket管道的服务器
- 使用Boost ASIO查找服务器IP
- Boost.Asio 异步服务器.限制为一个连接
- 在 Boost ASIO 服务器中处理生命周期
- Boost ASIO async_read 没有从服务器读取数据
- boost/asio:非常简单的聊天服务器无法访问收到的消息
- 异步服务器在创建boost :: asio后立即关闭
- 运行 boost::asio 异步服务器以及命令循环