title: using a non-blocking socket connection in C
body: <p>I'm changing a socket connection in a script to a non-blocking connection. In a tutorial I found the lines:</p>
  
  <pre><code>x=fcntl(s,F_GETFL,0);              // Get socket flags
  fcntl(s,F_SETFL,x | O_NONBLOCK);   // Add non-blocking flag
  </code></pre>
  
  <p>So I added them after I create my socket and before the connect statement. And it's no longer blocking :) but it also doesn't connect. I'm not getting any errors, the connect is just returning -1. If I comment these lines out it connects. </p>
  
  <p>What else do I need to add to get a non-blocking connection to connect? </p>