Following code is TCP server program just send back “HELLO!!” to client.
When I run server with port 80, bind() is returned Permission denied
.
P
Only the root user is allowed to bind to ports <= 1024. Every ports > 1024 can be bound to by normal users.
Try executing your program as root or with sudo
.
you have to run your application with super user account (root)
Run your application with sudo
command
Ports below 1024 are considered "privileged" and can only be bound to with an equally privileged user (read: root).
Anything above and including 1024 is "free to use" by anyone.
OT: you may know this already, but the port in your example is that for HTTP web servers. Anything listening to this port should speak HTTP, too. A simple "hello world" does not suffice. ;-)