title: I got problems with making a Python socket server receive commands from a Python socket client
body: <p>I got problems with making a Python socket server receive commands from a Python socket client. The server and client can send text to each other but I can't make text from the client trigger an event on the server. Could any one help me? I'm using Python 3.4.</p>
  
  <p>server.py</p>
  
  <pre><code>import socket 
  
  host = ''
  port = 1010
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
  s.bind((host, port)) 
  s.listen(1) 
  conn, addr = s.accept() 
  print ("Connection from", addr) 
  while True: 
      databytes = conn.recv(1024)
      if not databytes: break
      data = databytes.decode('utf-8')
      print("Recieved: "+(data))
      response = input("Reply: ")
      if data == "dodo":
          print("hejhej")
      if response == "exit": 
          break
      conn.sendall(response.encode('utf-8')) 
  conn.close()
  </code></pre>
  
  <p>In server.py I tried to make the word "dodo" trigger <code>print("hejhej")</code>.</p>
  
  <p>client.py</p>
  
  <pre><code>import socket 
  
  host = '127.0.0.1'
  port = 1010 
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
  s.connect((host, port)) 
  print("Connected to "+(host)+" on port "+str(port)) 
  initialMessage = input("Send: ") 
  s.sendall(initialMessage.encode('utf-8'))  
  
  while True: 
   data = s.recv(1024) 
   print("Recieved: "+(data.decode('utf-8')))
   response = input("Reply: ") 
   if response == "exit": 
       break
   s.sendall(response.encode('utf-8')) 
  s.close()
  </code></pre>