title: Polling using Select function in C++ on Windows
body: <p>I am new in <code>Socket Programming</code>. I am trying to create a Application that uses <code>Sockets</code> for Communication.</p>
  
  <p>I have doubt in the Receive function because sometime it just hangs in <code>recvfrom</code> function.
  I am using <code>select</code> function for polling. It works when Camera is connected but If I remove Camera it doesn't show the Error Message.</p>
  
  <p><strong>My Code for Polling:</strong> </p>
  
  <pre><code>FD_ZERO(&amp;m_readFds);
  FD_SET(Sock, &amp;m_readFds);
  
  m_timeInterval.tv_usec = 30;            //30 Microseconds for Polling
  m_socketLength = sizeof(m_cameraInfo);
  
  m_lastBlockId = -1;
  
  while (m_acquiringThreadStatus)
  {
      FD_CLR(Sock, &amp;m_readFds);
      FD_SET(Sock, &amp;m_readFds);
  
      m_receivingStatus = select(Sock + 1, &amp;m_readFds, NULL, NULL, &amp;m_timeInterval);
      if (m_receivingStatus &lt; 0)
      {
          std::cout &lt;&lt; "No Data to Receive"&lt;&lt;std::endl;
      }
      else
      {
          if ((m_receivedBytes = recvfrom(Sock, m_packetBuffer, RECEIVING_BUFFER_SIZE, 0, (struct sockaddr*)&amp;m_cameraInfo, &amp;m_socketLength)) == SOCKET_ERROR)
          {
              std::cout &lt;&lt; "ERROR" &lt;&lt; std::endl;
          }
          else
          {
              std::cout&lt;&lt;"Data Received"&lt;&lt;std::endl;
          }
       }
  }
  </code></pre>
  
  <p>An one more question is that when I continously printing the <code>Data Received</code> Statement after sometime  It stop. So how can I increase the size of Socket <code>Receiving Buffer</code>.</p>
  
  <p>Thanks in Advance</p>
  
  <p><strong>Edit</strong></p>
  
  <pre><code>SOCKET m_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if(m_sock == INVALID_SOCKET)
  {
  // Error
  }
  else
  {
  //In the else part bind the socket 
  }
  </code></pre>