title: python select.select() on Windows
body: <p>I'm testing UDP punching using code from <a href="https://gist.github.com/koenbollen/464613" rel="noreferrer">here</a>. It works on Linux however reports error on Windows. Here's the code snippet where the error occurs:</p>
  
  <pre><code>while True:
      rfds, _, _ = select([0, sockfd], [], [])  # sockfd is a socket
      if 0 in rfds:
          data = sys.stdin.readline()
          if not data:
              break
          sockfd.sendto(data, target)
      elif sockfd in rfds:
          data, addr = sockfd.recvfrom(1024)
          sys.stdout.write(data)
  </code></pre>
  
  <p>And error msg:</p>
  
  <pre><code>Traceback (most recent call last):
    File "udp_punch_client.py", line 64, in &lt;module&gt;
      main()
    File "udp_punch_client.py", line 50, in main
      rfds, _, _ = select([0, sockfd], [], [])
  select.error: (10038, '')
  </code></pre>
  
  <p>I know this error has some thing to do with the <code>select</code> implementation on Windows, and everyone quote this:</p>
  
  <blockquote>
    <p><strong>Note</strong> File objects on Windows are not acceptable, but sockets are. On
    Windows, the underlying select() function is provided by the WinSock
    library, and does not handle file descriptors that don’t originate
    from WinSock.</p>
  </blockquote>
  
  <p>So I got two questions:  </p>
  
  <ol>
  <li>What does <code>0</code> in <code>[0, sockfd]</code> mean? Is this some sort often-used technique? </li>
  <li>If <code>select</code> only works with <code>socket</code> on Windows, How to make the code Windows compatible?</li>
  </ol>
  
  <p>Thank you.  </p>