title: TCP Python Socket Server Response
body: <p>I'm writing a TCP python script that will act as a server and retrieve a temperature reading from a machine (the client). I need to pass a command to the client from the server and listen for an output of the response. I successfully reach the cmd definition line, but when s.accept() is called I'm left hanging with no response from the client.</p>
  
  <p>Server.py</p>
  
  <pre><code>import socket
  port = 7777
  ip = raw_input('192.168.62.233')
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.bind((ip, port))
  s.listen(1)
  print "waiting on port: ", port
  
  while True:
      cmd = raw_input('KRDG? A[term]')#command send to client
  
      conn, addr = s.accept()
  
      s.send(cmd)
  
      print "It sent"
  
      data = conn.recv(4096)
  
      print "Received:", data, " from address ", addr
  </code></pre>
  
  <p>Edit:</p>
  
  <p>I believe you're correct, I should consider my code the client and temperature readout at the server. I do now get left hanging after "here 2" when I go to s.recv(). </p>
  
  <p>Client.py</p>
  
  <pre><code>import socket
  
  ip = '192.168.62.233'
  port = 7777              # The same port as used by the server
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect((ip, port))
  
  print 'here'
  s.send('KRDG? A[term]')
  
  print 'here 2'
  data = s.recv(4096)
  print 'here 3'
  s.close()
  print 'Received', repr(data)
  </code></pre>