title: Simple Python chat app with sockets
body: <p>I'm trying to make a simple client/server chat app in Python with sockets, and eventually turn it into a networked game of Rock, Paper, Scissors.</p>
  
  <p>I found a guide online to create the client/server but I'm having trouble modifying the loops so that each script listens for the other, receives a message, then shows a raw_input that becomes the message sent to the other script, then so on. Here's the code:</p>
  
  <p><strong>client.py</strong></p>
  
  <pre><code>#!/usr/bin/python   
  
  import socket           
  
  s = socket.socket()        
  host = socket.gethostname()
  port = 12221             
  
  s.connect((host, port))
  while True:
      z = raw_input("Enter something for the server: ")
      s.send(z) 
      print s.recv(1024) 
  </code></pre>
  
  <p><strong>server.py</strong></p>
  
  <pre><code>#!/usr/bin/python          
  
  import socket         
  
  s = socket.socket()        
  host = socket.gethostname() 
  port = 12221               
  s.bind((host, port))   
  
  s.listen(5)
  
  while True:
     c, addr = s.accept()
     print 'Got connection from', addr
     print c.recv(1024)
     q = raw_input("Enter something to this client: ")
     c.send(q)             
  </code></pre>
  
  <p>Any help? Thank you.</p>