title: Python select used in python program
body: <p>I was reading a <a href="https://code.google.com/p/python-proxy/source/browse/trunk/PythonProxy.py" rel="nofollow">proxy server</a> developed using python</p>
  
  <p>I don't understand the method <code>def _read_write</code> which uses <code>select</code> to write client and server socket. </p>
  
  <pre><code>def _read_write(self):
      time_out_max = self.timeout/3
      socs = [self.client, self.target]
      count = 0
      while 1:
          count += 1
          (recv, _, error) = select.select(socs, [], socs, 3)
          if error:
              break
          if recv:
              for in_ in recv:
                  data = in_.recv(BUFLEN)
                  if in_ is self.client:
                      out = self.target
                  else:
                      out = self.client
                  if data:
                      out.send(data)
                      count = 0
          if count == time_out_max:
              break
  </code></pre>
  
  <p>Please someone help me to understand.</p>