title: Sockets on Ubuntu (operation not permitted)
body: <p>I'm newbee and just making my first steps in c++ under linux.
  So I have some task about sockets. I'm following guides, especially <a href="http://beej.us/guide/bgipc/output/html/multipage/unixsock.html" rel="noreferrer">this</a> one. And code examples are not working. I started with this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;string.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;sys/un.h&gt;
  
  #define SOCK_PATH "echo_socket"
  
  int main(void)
  {
      int s, s2, t, len;
      struct sockaddr_un local, remote;
      char str[100];
  
      if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
          perror("socket");
          exit(1);
      }
  
      local.sun_family = AF_UNIX;
      strcpy(local.sun_path, SOCK_PATH);
      unlink(local.sun_path);
      len = strlen(local.sun_path) + sizeof(local.sun_family);
      if (bind(s, (struct sockaddr *)&amp;local, len) == -1) {
          perror("bind");
          exit(1);
      }
  return 0;
  }
  </code></pre>
  
  <p>I've figured out that to compile it (Code::Blocks) there must be one more include:</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  </code></pre>
  
  <p>But after successful run I'm getting message "Bind: Operation not permitted". What is wrong? I've tried to run it under root and still it is not working.</p>