Ad

Binding A Socket To Port 80 In Ansi C

- 1 answer

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?

Ad

Answer

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

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

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.

Ad
source: stackoverflow.com
Ad