title: Socket programing Permission denied
body: <p>Following code is TCP server program just send back “HELLO!!” to client.</p>
  
  <p>When I run server with port 80, bind() is returned <code>Permission denied</code>.</p>
  
  <p>Port 12345 is OK.</p>
  
  <p>How can I use port 80 for this server program?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;netinet/in.h&gt;
  
  int
  main(){
      int sock0;
      struct sockaddr_in addr;
      struct sockaddr_in client;
      int len;
      int sock;
      char *message;
      message = "HELLO !!";
      sock0 = socket(AF_INET,SOCK_STREAM,0);
      addr.sin_family = AF_INET;
      addr.sin_port = htons(80);
      inet_pton(AF_INET,"127.0.0.1",&amp;addr,sizeof(addr));
      bind(sock0,(struct sockaddr *)&amp;addr,sizeof(addr));
      perror("bind");
      len = sizeof(client);
      sock = accept(sock0,(struct sockaddr *)&amp;client,&amp;len);
      perror("accept");
      write(sock,message,sizeof(message));
      perror("write");
      close(sock);
      return 0;
  }
  </code></pre>