title: Streaming TCP data to a Client with Python
body: <p>I have read several different SO posts on using python as a TCP client and am not able to connect to a server sending data via TCP at 1hz which is hosted locally.  The connection parameters I am using are:</p>
  
  <pre><code>import socket
  client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  ip=socket.gethostbyname("127.0.0.1")
  port=1234
  address=(ip,port)
  client.connect(address)
  while True:
      print("test1")
      data = client.recv(1024)
      print("test2")
      print(data)
  </code></pre>
  
  <p>I believe that it is failing on the second line of the while statement but do not know why because it hangs and I am not given an error.  Below are links to the SO articles, I have read and I have attached a screenshot from a TCP client tool that I am able to connect to the data server with.  I'm expecting the data to stream in my print statement, is this not how it works? Whats the best way to make a persistent connection to a TCP connection with python?</p>
  
  <p>Researched:
  <a href="https://stackoverflow.com/questions/7749341/very-basic-python-client-socket-example">(Very) basic Python client socket example</a>,<a href="https://stackoverflow.com/questions/42792834/python-continuous-tcp-connection">Python continuous TCP connection</a>,<a href="https://stackoverflow.com/questions/41102775/python-stream-data-over-tcp">Python stream data over TCP</a></p>
  
  <p><a href="https://i.stack.imgur.com/elYyz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/elYyz.png" alt="enter image description here"></a></p>