title: Non Blocking recv() in C Sockets
body: <p>I am using an infinite loop in sockets in which if it receives some data it should receive it or if it wants to send data it sends. Something like given below. I am using select. I have only one socket sd.</p>
  
  <pre><code>fd_set readsd;
  int maxsd = readsd +1;
  // all those actions of setting maxsd to the maximum fd +1 and FDSETing the FDs.
  while(1)
  {
       FD_ZERO(&amp;read_sd);
       FD_SET(sd, &amp;read_sd);
       if(FD_ISSET(sd, &amp;readsd))
       {
         //recv call
       }
       else
       {
         //send call
       }
  }
  </code></pre>
  
  <p>As far as I know, select selects one of the socket descriptors on which data arrives first. But here I have only one socket, and I want to recv if there is some data or I want to send otherwise.</p>
  
  <p>In that case, is the code given above fine? Or there is some other option for me which I don't know about?</p>