在ANSI C绑定socket到端口80 [英] Binding a socket to port 80 in ansi c

查看:191
本文介绍了在ANSI C绑定socket到端口80的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试绑定端口8​​0在C套接字,我总是得到错误,我没有使用此端口的权限。有一种简单的方法来获得此权限吗?

When I try to bind port 80 to a socket in c, i always get the error, that I don't have permission to use this port. is there an easy way to get this permission?

推荐答案

通常只有超级用户(root)可以绑定到特权端口(即,低于1024的端口号)。

Usually only the superuser (root) can bind to 'privileged' ports (i.e. those port numbers below 1024).

这意味着你要么运行您的程序以root或让你的可执行文件的SUID根'。

This means that you either have to run your program as root or make your executable 'suid root'.

这两种有安全后果,所以你可能要考虑使用的suid方法,并放弃超级用户权限,一旦绑定已经调用。

Both of these have security consequences so you may want to consider using the suid approach and relinquishing superuser privileges once the bind call has been made.

这篇关于在ANSI C绑定socket到端口80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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