title: Turning on O_NONBLOCKING in C on LINUX
body: <p>***Background****
  I am new to TCP so I have question that may be a bit basic. I am trying to turn on O_NONBLOCK on a socket that is receiving data. Up until now I have tried to different ways to set O_NONBLOCK, itcl() and fcntl(). Right now I am trying to get fcntl() to work. </p>
  
  <p>My Question: Are you supposed to set O_NONBLOCK before you connect the socket or after?</p>
  
  <p>**my current implementation of fcntl() is based off off the link before the code:</p>
  
  <p><a href="https://stackoverflow.com/questions/2149798/how-to-reset-a-socket-back-to-blocking-mode-after-i-set-it-to-nonblocking-mode">How to reset a socket back to blocking mode (after I set it to nonblocking mode)?</a></p>
  
  <pre><code>//set socket to NONBlocking
  on = fcntl(Socket,F_GETFL);
  on = (on | O_NONBLOCK);
  if(fcntl(Socket,F_SETFL,on) &lt; 0)
      {
         perror("turning NONBLOCKING on failed\n");
      }
  
  // DO CONNECT
  rc = connect()
  </code></pre>
  
  <p>Thank you for taking the time to look at this</p>