title: Not getting complete data from socket connection
body: <p>I am trying to write a socket client that receives a data stream from the server.
  I am able to get the first couple of bytes but then it breaks.</p>
  <p>Code:</p>
  <pre><code>import socket
  import sys
  
  readOut = 0                 # serial data
  ipaddr = &quot;192.168.1.246&quot;    # ip address of digital thermometer socket server
  
  #def hitsocket(ipaddr):
      #with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
  print (&quot;Starting up&quot;)
  connected = False
  
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
      try:
          s.connect((ipaddr , 8080))
          amount_received = 0
          while True:
              data = s.recv(1024)
              amount_received += len(data)
              if not data:
                  break
              print(amount_received, end=&quot;\n&quot;)
              while True:
                  print (&quot;Reading: &quot;, amount_received)
                  if &quot;Fahrenheit&quot; in amount_received:
                      cread = amount_received[22:-2]
                      newcread = float(cread)
                      print(&quot;readOut &quot;, amount_received, &quot;cread &quot;, cread, 
                            &quot;newcread &quot;, newcread)
                      break
                  print (&quot;Restart&quot;)
      finally:
          print(sys.stderr, 'closing socket')
          s.close()
  </code></pre>
  <p>Output:</p>
  <pre><code>Starting up
  19
  Writing:  1
  Reading:  19
  &lt;_io.TextIOWrapper name='&lt;stderr&gt;' mode='w' encoding='UTF-8'&gt; closing socket
  Traceback (most recent call last):
    File &quot;climatemngrDebug-v3.py&quot;, line 58, in &lt;module&gt;
      if &quot;Fahrenheit&quot; in amount_received:
  TypeError: argument of type 'int' is not iterable
  </code></pre>
  <p>netcat output of socket:</p>
  <pre><code>kermit@whale:~/dev $ netcat 192.168.1.246 8080
  mcp9809 Fahrenheit 72.0500
  mcp9809 Fahrenheit 72.0500
  mcp9809 Fahrenheit 72.0500
  mcp9809 Fahrenheit 72.1625
  mcp9809 Fahrenheit 72.0500
  mcp9809 Fahrenheit 72.0500
  mcp9809 Fahrenheit 72.1625
  mcp9809 Fahrenheit 72.0500
  </code></pre>
  <p>How do I get my socket to output a complete line of data?</p>
  <p>I have read the python doc, I have looked at the other examples, but I'm still getting it wrong.</p>