title: Python Server & Client won't communicate
body: <p>I've been following examples on a server and client communication within Python but I cannot get the server to constantly listen for new messages, print them and send them back for the client to print it as well. Any ideas what I'm doing wrong?
  Server code:</p>
  
  <pre><code>#Imports
  import socket
  
  #Define socket address
  TCP_IP = '0.0.0.0'  # consider all incoming IPs 
  TCP_PORT = 5000  # port# communicating with the client
  BUFFER_SIZE = 1024  # buffer size for receiving data
  
  #Create socket    IPv4            TCP
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  print "Socket created"
  
  
  s.bind((TCP_IP, TCP_PORT))
  
  s.listen(20)
  print "Waiting for a Cli_socket..."
  
  #Wait for Cli_sockect
  while True:
      while True:
          # accept Cli_sockection 
          Cli_sock, addr = s.accept()
          print "Cli_sockected with " + addr[0] + " " + str(addr[1])
          # get message from client
          message = Cli_sock.recv(BUFFER_SIZE)
          print message
          # check that there is a message   
          if not message:
              break
          # send message to client
          Cli_sock.send(message)
          print "Sent message"
  
      s.close()
      print "Socket Closed"
  </code></pre>
  
  <p>Client code:</p>
  
  <pre><code># a simple client socket
  import socket
  
  # define socket address
  TCP_IP = '127.0.0.1'  # ip of connecting server
  TCP_PORT = 5000  # port communicating server
  BUFFER_SIZE = 1024  # buffer size receiving data
  
  
  # create socket IPv4 &amp; TCP protocol
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  print "Socket created successfully."
  
  # connect to server
  s.connect((TCP_IP, TCP_PORT))
  print "Established connection with the server."
  data = s.recv(BUFFER_SIZE)
  
  while True:
      print ("Message to send:")
      message = raw_input()
      s.send(message)
      print "Message sent to server: %s." % message
      print ("Message Recv:%s\n" % data)
  </code></pre>