Socket programing Permission denied

前端 未结 3 2028
醉梦人生
醉梦人生 2020-12-17 11:03

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

相关标签:
3条回答
  • 2020-12-17 11:11

    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.

    0 讨论(0)
  • 2020-12-17 11:12

    you have to run your application with super user account (root)

    Run your application with sudo command

    0 讨论(0)
  • 2020-12-17 11:31

    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. ;-)

    0 讨论(0)
提交回复
热议问题