title: Python socket - Messages not always registering on server
body: <p>In trying to familiarize myself with the socket library, I have a simple server and client setup. Basically I've stumbled through and am able to set up connection and get the server and client to talk to each other. To make it more interactive, I have client.py able to send text through the command line. Everything appears to be working properly (with the exception of the server side tearing down connection properly if client input is blank), if I type a message from the client side, it spits it right back out to me. In this example, I have it set up for the server side to print the text as well. What I noticed was, that the server side doesn't alway 'register' what it being sent from the client. I am trying to figure out why this is the case. For being a test, it doesn't really affect anything, I just can't figure out what is taking place behind the scenes.</p>
  
  <p>EDIT:
  Actually, after playing around with it for a bit, it appears every other message is being printed out to the server console. I've still yet to figure out why this is the case</p>
  
  <p>Server side:</p>
  
  <pre><code>#server.py
  import  socket
  
  ss = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  ss.bind(('127.0.0.1',5000))
  ss.listen(5)
  
  while True:
      conn, addr = ss.accept()
  
      with conn:
          print ('Connected by', addr)
          while True:
              data = conn.recv(4096)
              print (data)
              if not data:
                  print ("nothing received from client")
                  ss.close()
                  break
  </code></pre>
  
  <p>Client side: </p>
  
  <pre><code>#client.py
  import socket
  
  server = 'localhost'
  port = 5000
  
  s = socket. socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect(('127.0.0.1', 5000))
  s.send(bytes(b'Client has connected'))
  
  while True:
      msg = input()
      s.send(bytes(input(msg),'utf-8'))
      if not msg:
          print ("Server should tear down connection...")
          # s.close()
          break
  </code></pre>