title: python socket recv hanging
body: <p>I'm trying to connect my codes those are written in python and processing(java). python hangs until it gets some data. it makes some problem for me! i use select.select but it hangs again until it gets some data. I am pleased if you help me.</p>
  
  <p>here is my python socket class:</p>
  
  <pre><code>import socket
  import select
  import time
  
  class client():
      def __init__(self,HOST,PORT):
          self.HOST = HOST              # Symbolic name meaning all available interfaces
          self.PORT = PORT              # Arbitrary non-privileged port
          self.connect()
      def connect(self):
          self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.s.bind((self.HOST, self.PORT))
          self.s.listen(1)
          self.conn, self.addr = self.s.accept()
          print('Connected by', self.addr)
          return
      def readData(self):
          do_read = False
          try:
              r, _, _ = select.select([self.conn], [], [])
              do_read = bool(r)
          except socket.error:
              pass
          if do_read:
              # ready to receive
              data = self.conn.recv(1024)
              return data
          return 0
  
  print('hello')
  x=client('localhost',5204);
  #print('Connected by', addr)
  while True:
      data=x.readData();
      if data:
          print(data)
  </code></pre>