title: Bind failed: Address already in use
body: <p>I am attempting to bind a socket to a port below:  </p>
  
  <pre><code>if( bind(socket_desc,(struct sockaddr *) &amp;server, sizeof(server)) &lt; 0)
  {
      perror("bind failed. Error");
      return 1;
  }
  puts("bind done");
  </code></pre>
  
  <p>But it gives:</p>
  
  <pre><code>$ ./serve   
  Socket created    
  bind failed. Error: Address already in use
  </code></pre>
  
  <p>Why does this error occur?</p>