Linux使用Boost Asio拒绝套接字绑定权限 [英] Linux denies permission on socket bind using boost asio

查看:157
本文介绍了Linux使用Boost Asio拒绝套接字绑定权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在绑定套接字时遇到问题,并且以用户身份运行该程序时遭到拒绝.这行代码会产生错误.

I'm having a problem binding a socket and I get permision denied when running the program as a user. this line of code generates an error.

_acceptor = new boost::asio::ip::tcp::acceptor(io, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), serverPort)); 错误是

_acceptor = new boost::asio::ip::tcp::acceptor(io, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), serverPort)); the error is

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'

what():bind:权限被拒绝

what(): bind: Permission denied

但是,如果我以root身份运行,则可以正常运行.我尝试使用

However, if I run as root it works fine. I've tried disabling apparmor and firewall with

sudo service apparmor stop
sudo ufw disable

但是我仍然有问题.我是否缺少可以拒绝渗透的东西? 我真的很想弄明白这一点,因为我不希望以root用户身份运行我的IDE和未经验证的程序.

but I still have the problem. Am I missing something that could deny permision? I'd really like to figure this out as I don't like running my IDE and an unproven program as root.

我正在运行xubuntu 13.10,并安装了所有更新.

I'm running xubuntu 13.10 with all updates installed.

推荐答案

在UNIX系统上,仅将第一个1024端口限制为root用户,因此,如果serverPort< 1024,您应该尝试> 1024

On unix systems, the first 1024 port are restricted to the root user only so if serverPort < 1024 you should try something > 1024

这篇关于Linux使用Boost Asio拒绝套接字绑定权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆