title: Implementing UDP sockets with select in C
body: <p>I am implementing a socket programming project in C. I am using <code>select()</code> for waiting for data from client. I have two UDP sockets and <code>select()</code> is always ignoring one of my sockets.</p>
  
  <p>Can anybody briefly describe where should I start looking for it? This is what my server is doing</p>
  
  <pre><code>waitThreshold.tv_sec = 5000; 
  waitThreshold.tv_usec = 50; 
  if (sd &gt; sd1)
      max_sd = (sd + 1);
  else if(sd1 &gt; sd)   
      max_sd = (sd1 + 1);
  FD_ZERO(&amp;read_sds); 
  FD_SET(sd, &amp;read_sds); 
  FD_SET(sd1, &amp;read_sds);   
  
  ret = select(max_sd, &amp;read_sds, NULL, NULL, &amp;waitThreshold); 
  if (ret &lt; 0) {
      printf("\nSelect thrown an exception\n");   
      return 0;
  } else if (FD_ISSET(sd, &amp;read_sds)) { 
      // code for socket one 
  } else if (FD_ISSET(sd1, &amp;read_sds)) {
      // code for socket two 
  }
  </code></pre>