title: How can I refuse a socket connection in C?
body: <p>If I want to accept a connection I call <code>accept</code>, but how can I refuse a connection?</p>
  
  <p>In a working socket echo client I have this if statement. In the echo server, how can I make the echo client reach this <code>printf</code> statement?    </p>
  
  <pre><code>...
  if (connect(sock, (struct sockaddr *) &amp;server, sizeof(server)) &lt; 0) { 
      printf("Connecting failed\n"); 
      return 1; 
  }
  ...
  </code></pre>